BZOJ1923: [Sdoi2010]外星千足虫
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1923
高斯消元。
(bitset好优越啊。。
#include<cstring> #include<iostream> #include<algorithm> #include<cstdio> #include<queue> #include<bitset> #define rep(i,l,r) for (int i=l;i<=r;i++) #define down(i,l,r) for (int i=l;i>=r;i--) #define clr(x,y) memset(x,y,sizeof(x)) #define maxn 2005 using namespace std; bitset<1005> a[2005]; int n,m,l,r,ans; char s[maxn]; int read(){ int x=0,f=1; char ch=getchar(); while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while (isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();} return x*f; } void gs(){ rep(i,1,n){ int now=i; while (now<=m&&a[now][i]==0) now++; ans=max(ans,now); if (now==m+1) {ans=-1; return;} swap(a[now],a[i]); rep(j,1,m) if (i!=j&&a[j][i]) a[j]^=a[i]; } } int main(){ n=read(); m=read(); rep(i,1,m){ scanf("%s",s); a[i][n+1]=read(); rep(j,1,n) a[i][j]=s[j-1]-'0'; } gs(); if (ans==-1) puts("Cannot Determine"); else { printf("%d\n",ans); rep(i,1,n) if (a[i][n+1]) puts("?y7M#"); else puts("Earth"); } return 0; }