diff --git a/AcWing/208/208.cpp b/AcWing/208/208.cpp new file mode 100644 index 00000000..0f203efb --- /dev/null +++ b/AcWing/208/208.cpp @@ -0,0 +1,80 @@ +#include +#include + +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; +} diff --git a/AcWing/208/data/2.ans b/AcWing/208/data/2.ans new file mode 100644 index 00000000..7f81391a --- /dev/null +++ b/AcWing/208/data/2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:558c37bc755dac9b1980fed80b4035ef9d8cb3eb2b9a8f16364bd2fae96a95d5 +size 37 diff --git a/AcWing/208/data/2.in b/AcWing/208/data/2.in new file mode 100644 index 00000000..0238d3e2 --- /dev/null +++ b/AcWing/208/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a05760426dbe418877ec4c545dca5fedb4c5326d9f7bf300718562c5af3870cd +size 1115