0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00
Baoshuo Ren 2022-05-10 21:19:16 +08:00
parent b79303d612
commit baec5db7e8
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
3 changed files with 86 additions and 0 deletions

80
AcWing/208/208.cpp Normal file
View File

@ -0,0 +1,80 @@
#include <cstring>
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 35;
int t, n, a[N][N];
int gauss() {
int r, c;
for (r = c = 1; c <= n; c++) {
int t = r;
for (int i = r; i <= n; i++) {
if (a[i][c]) t = i;
}
if (!a[t][c]) continue;
std::swap(a[t], a[r]);
for (int i = r + 1; i <= n; i++) {
if (a[i][c]) {
for (int j = n + 1; j >= c; j--) {
a[i][j] ^= a[r][j];
}
}
}
r++;
}
int res = 1;
if (r <= n) {
for (int i = r; i <= n; i++) {
if (a[i][n + 1]) return -1;
res <<= 1;
}
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
memset(a, 0x00, sizeof(a));
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i][n + 1];
}
for (int i = 1, x; i <= n; i++) {
cin >> x;
a[i][n + 1] ^= x;
a[i][i] = 1;
}
int x, y;
while (cin >> x >> y, x || y) a[y][x] = 1;
int r = gauss();
if (r == -1) {
cout << "Oh,it's impossible~!!" << endl;
} else {
cout << r << endl;
}
}
return 0;
}

BIN
AcWing/208/data/2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AcWing/208/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.