"Gaussian elimination" "Xor Equations" "Bitset" bzoj1923 [Sdoi2010] alien thousand-legged worm

Source: Internet
Author: User
Tags bitset

The number of solutions for the Xor equation Group is determined:

--Mo Tao--"Gaussian elimination solution of the Xor Equation Group"

Use the number of equations to determine: When the first unknown is eliminated, it is recorded that the nearest I-bit coefficient of the first equation is not the 0の equation, which Max uses the number of equations.

Use Bitset acceleration.

#include <cstdio> #include <cmath> #include <algorithm> #include <bitset>using namespace std;# Define N 1001#define M 2001int n,m,use;char s[n];bool a[m][n+1],x[n],b[m];bitset<n+1>b[m];bool Guass_jordan () { for (int i=1;i<=m;++i) for  (int j=1;j<=n;++j)    b[i][j]=a[i][j];for (int i=1;i<=m;++i)  b[i][n+1]= b[i];for (int i=1;i<=n;++i)  {  int j=i;  for (; j<=m;++j)    if (B[j][i]) break      ;  if (j==m+1)  return 0;  Use=max (use,j);  Swap (b[i],b[j]);  for (J=1;J<=M;++J)    if (I!=j&&b[j][i])      b[j]^=b[i];  } for (int i=1;i<=m;++i) X[i]=b[i][n+1];return 1;} int main () {scanf ("%d%d", &n,&m), for (int i=1;i<=m;++i)  {  scanf ("%s%d", S,&b[i]);  for (int j=0;j<n;++j)    a[i][j+1]=s[j]-' 0 ';  } if (!guass_jordan ())  puts ("cannot determine"), else  {  printf ("%d\n", use);  for (int i=1;i<=n;++i)    puts (X[i]? "? y7m# ":" Earth ");  } return 0;}

"Gaussian elimination" "Xor Equations" "Bitset" bzoj1923 [Sdoi2010] alien thousand-legged worm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.