1 条题解
-
0问号 (周文浩) LV 10 @ 2024-5-13 17:17:49
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 35; int t,n; int a[N][N],b[N]; int gs() { int l1,l2; for(l1=l2=1;l1<=n&&l2<=n;l1++,l2++) { int tmp = l1; while(tmp<=n&&!a[tmp][l2])tmp++; if(tmp>n) { l1--; continue; } if(tmp!=l1) for(int j=l2;j<=n+1;j++)swap(a[l1][j],a[tmp][j]); for(int i=l1+1;i<=n;i++)if(a[i][l2]) for(int j=l2;j<=n+1;j++)a[i][j]^=a[l1][j]; } for(int i=l1;i<=n;i++) if(a[i][n+1])return 0; return (1<<(n-l1+1)); } int main() { scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&b[i]); for(int i=1;i<=n;i++) { scanf("%d",&a[i][n+1]); a[i][n+1]^=b[i]; a[i][i]=1; } int x,y; while(scanf("%d%d",&x,&y)) { if(!x&&!y)break; a[y][x]=1; } int ans = gs(); if(!ans)puts("Oh,it's impossible~!!"); else printf("%d\n",ans); } return 0; }
- 1
信息
- ID
- 119
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 19
- 已通过
- 9
- 上传者