From baec5db7e878236f479266f707993ef4e16e3f71 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Tue, 10 May 2022 21:19:16 +0800 Subject: [PATCH] =?UTF-8?q?208.=20=E5=BC=80=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/14093772/ --- AcWing/208/208.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++ AcWing/208/data/2.ans | 3 ++ AcWing/208/data/2.in | 3 ++ 3 files changed, 86 insertions(+) create mode 100644 AcWing/208/208.cpp create mode 100644 AcWing/208/data/2.ans create mode 100644 AcWing/208/data/2.in 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