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