标签:其他 cst 四种 container wap -- fine 否则 ret
2 3 0 0 0 1 1 1 1 2 1 3 2 1 2 3 3 1 3 2 0 0 3 0 0 0 1 0 1 1 2 2 1 0 0Sample Output
4 Oh,it‘s impossible~!!Hint
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; #define maxn 50 int a[maxn][maxn], length, ans[maxn]; void Gauss() { int i, j, k, r, col; for(k = 0, col = 0; k < length&&col < length; k++, col++) { int i = k; while(i < length&&a[i][col] == 0) i++; if(a[i][col] == 0) { k--; continue; } if(i > k) { for(r = col; r <= length; r++) { swap(a[i][r], a[k][r]); } } for(i = k+1; i < length; i++) { if(a[i][col]) { for(j = col; j <= length; j++) a[i][j] ^= a[k][j]; } } } for(i = k; i <length; i++) { if(a[i][length] != 0) { printf("Oh,it‘s impossible~!!\n"); return; } } printf("%d\n",(1 << (length - k))); return; } int main() { int i, T; scanf("%d", &T); while(T--) { memset(a, 0, sizeof(a)); scanf("%d",&length); for(i = 0; i < length; i++) { scanf("%d", &a[i][length]); a[i][i] = 1; } int x; for(i = 0; i <length; i++) { scanf("%d", &x); a[i][length] = a[i][length]^x; } int m, n; while(~scanf("%d %d", &m, &n)) { if(m+n == 0) break; a[n-1][m-1] = 1; } Gauss(); } return 0; }
标签:其他 cst 四种 container wap -- fine 否则 ret
原文地址:https://www.cnblogs.com/mrh-acmer/p/9490675.html