From e02599f1c41c3ab80b328f10c5bee6248859d11b Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 12 Nov 2022 11:33:02 +0800 Subject: [PATCH] =?UTF-8?q?#160.=20=E3=80=90=E6=A8=A1=E6=9D=BF=E3=80=91k?= =?UTF-8?q?=20=E5=A4=A7=E5=BC=82=E6=88=96=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/64185 --- S2OJ/160/160.cpp | 70 ++++++++++++++++++++++++++++++++++++++ S2OJ/160/data/problem.conf | 3 ++ S2OJ/160/data/xor1.ans | 3 ++ S2OJ/160/data/xor1.in | 3 ++ S2OJ/160/data/xor2.ans | 3 ++ S2OJ/160/data/xor2.in | 3 ++ S2OJ/160/data/xor3.ans | 3 ++ S2OJ/160/data/xor3.in | 3 ++ S2OJ/160/data/xor4.ans | 3 ++ S2OJ/160/data/xor4.in | 3 ++ S2OJ/160/data/xor5.ans | 3 ++ S2OJ/160/data/xor5.in | 3 ++ S2OJ/160/data/xor6.ans | 3 ++ S2OJ/160/data/xor6.in | 3 ++ S2OJ/160/data/xor7.ans | 3 ++ S2OJ/160/data/xor7.in | 3 ++ S2OJ/160/data/xor8.ans | 3 ++ S2OJ/160/data/xor8.in | 3 ++ S2OJ/160/data/xor9.ans | 3 ++ S2OJ/160/data/xor9.in | 3 ++ 20 files changed, 127 insertions(+) create mode 100644 S2OJ/160/160.cpp create mode 100644 S2OJ/160/data/problem.conf create mode 100644 S2OJ/160/data/xor1.ans create mode 100644 S2OJ/160/data/xor1.in create mode 100644 S2OJ/160/data/xor2.ans create mode 100644 S2OJ/160/data/xor2.in create mode 100644 S2OJ/160/data/xor3.ans create mode 100644 S2OJ/160/data/xor3.in create mode 100644 S2OJ/160/data/xor4.ans create mode 100644 S2OJ/160/data/xor4.in create mode 100644 S2OJ/160/data/xor5.ans create mode 100644 S2OJ/160/data/xor5.in create mode 100644 S2OJ/160/data/xor6.ans create mode 100644 S2OJ/160/data/xor6.in create mode 100644 S2OJ/160/data/xor7.ans create mode 100644 S2OJ/160/data/xor7.in create mode 100644 S2OJ/160/data/xor8.ans create mode 100644 S2OJ/160/data/xor8.in create mode 100644 S2OJ/160/data/xor9.ans create mode 100644 S2OJ/160/data/xor9.in diff --git a/S2OJ/160/160.cpp b/S2OJ/160/160.cpp new file mode 100644 index 00000000..33300305 --- /dev/null +++ b/S2OJ/160/160.cpp @@ -0,0 +1,70 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 55; + +int n, m, cnt; +unsigned long long x, k, a[N], p[N], ans; + +inline void insert(unsigned long long x) { + for (int i = 50; ~i; i--) { + if (x & (1ull << i)) { + if (a[i]) { + x ^= a[i]; + } else { + for (int k = 0; k < i; k++) { + if (x & (1ull << k)) x ^= a[k]; + } + + for (int k = i + 1; k <= 50; k++) { + if (a[k] & (1ull << i)) a[k] ^= x; + } + + a[i] = x; + return; + } + } + } +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> x; + + insert(x); + } + + for (int i = 0; i <= 50; i++) { + if (a[i]) p[cnt++] = a[i]; + } + + cin >> m; + + while (m--) { + cin >> k; + + if (cnt != n) k--; // 非空 + + if (k >= (1ull << cnt)) { + cout << -1 << endl; + } else { + ans = 0; + + for (int i = 0; i < cnt; i++) { + if (k & (1ull << i)) ans ^= p[i]; + } + + cout << ans << endl; + } + } + + return 0; +} diff --git a/S2OJ/160/data/problem.conf b/S2OJ/160/data/problem.conf new file mode 100644 index 00000000..cc801bf1 --- /dev/null +++ b/S2OJ/160/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:096e03354c9d445ec8a02f6d05a1aec42d1c5a1d745c36e66fd66d2457d6bdc3 +size 190 diff --git a/S2OJ/160/data/xor1.ans b/S2OJ/160/data/xor1.ans new file mode 100644 index 00000000..2e5f4af7 --- /dev/null +++ b/S2OJ/160/data/xor1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f4985d16aab0db29132fe1befbb470d1f4237c235cf3431ca49faa6393dd96f +size 121 diff --git a/S2OJ/160/data/xor1.in b/S2OJ/160/data/xor1.in new file mode 100644 index 00000000..02baa705 --- /dev/null +++ b/S2OJ/160/data/xor1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:994ac1c6830a64c22e67b7e8f94f2b1fb9ca80e1cbfb801302e3d303f6e44de3 +size 208 diff --git a/S2OJ/160/data/xor2.ans b/S2OJ/160/data/xor2.ans new file mode 100644 index 00000000..6300a376 --- /dev/null +++ b/S2OJ/160/data/xor2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1df05d262e0c3095fbb1165c4a7133cdd4ad1d12a231b085d33550c7fa5cf31 +size 84 diff --git a/S2OJ/160/data/xor2.in b/S2OJ/160/data/xor2.in new file mode 100644 index 00000000..07f6c338 --- /dev/null +++ b/S2OJ/160/data/xor2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25d529eec22b0cbf77c96ae83c7a5c41e1cebfabfccc00121d23b6e232c75926 +size 402 diff --git a/S2OJ/160/data/xor3.ans b/S2OJ/160/data/xor3.ans new file mode 100644 index 00000000..f01ec2c8 --- /dev/null +++ b/S2OJ/160/data/xor3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd0a17ae6946d6eae2f2652c7b75137eef9545f238634fb6427e019c031369d7 +size 397 diff --git a/S2OJ/160/data/xor3.in b/S2OJ/160/data/xor3.in new file mode 100644 index 00000000..ffe482b6 --- /dev/null +++ b/S2OJ/160/data/xor3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:318d6660e615dac1ebff640178ecc9ff37104d5fefe3a01f70ee5105bae76bc9 +size 1636 diff --git a/S2OJ/160/data/xor4.ans b/S2OJ/160/data/xor4.ans new file mode 100644 index 00000000..b223376f --- /dev/null +++ b/S2OJ/160/data/xor4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be90590f6d6bd4cf94f6d9f98623a80b4aace75bc182cc9420f99866f6ac3072 +size 2874 diff --git a/S2OJ/160/data/xor4.in b/S2OJ/160/data/xor4.in new file mode 100644 index 00000000..194ba297 --- /dev/null +++ b/S2OJ/160/data/xor4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ad88edbc9198b858fcedee3f5a258bdf139f103d860c95437e8c8b28ddf488b +size 9755 diff --git a/S2OJ/160/data/xor5.ans b/S2OJ/160/data/xor5.ans new file mode 100644 index 00000000..4ee6cb58 --- /dev/null +++ b/S2OJ/160/data/xor5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4aa29dbdff647692734415e021257c09470eff2845179336b37c5af530a79193 +size 2881 diff --git a/S2OJ/160/data/xor5.in b/S2OJ/160/data/xor5.in new file mode 100644 index 00000000..b2c7eef7 --- /dev/null +++ b/S2OJ/160/data/xor5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04259f6197e0a14e16299e1a2bc2e958c6e40d6a3dea99f501ead74fadd59ecc +size 20994 diff --git a/S2OJ/160/data/xor6.ans b/S2OJ/160/data/xor6.ans new file mode 100644 index 00000000..51f4eb4d --- /dev/null +++ b/S2OJ/160/data/xor6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edb636565cd3ce7948531c6c42bb2f4e36c0f4b2f15f1c9750a0ed601a60da3c +size 48111 diff --git a/S2OJ/160/data/xor6.in b/S2OJ/160/data/xor6.in new file mode 100644 index 00000000..55317b50 --- /dev/null +++ b/S2OJ/160/data/xor6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5c8b336e898993a5ba5d379fb14a9edb0dd735ff6f22d4f25d4b5c8e088c3b2 +size 242656 diff --git a/S2OJ/160/data/xor7.ans b/S2OJ/160/data/xor7.ans new file mode 100644 index 00000000..d5a8dfa3 --- /dev/null +++ b/S2OJ/160/data/xor7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:faa2ada4e0da082e24bac633af59958ea537c32c556d8553b987947e0040fcfc +size 74928 diff --git a/S2OJ/160/data/xor7.in b/S2OJ/160/data/xor7.in new file mode 100644 index 00000000..4779bf63 --- /dev/null +++ b/S2OJ/160/data/xor7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f9a3d5a3641cb4cb6ff958eaf57bd85c74a09cce2e9806d2410782246044e7b +size 612438 diff --git a/S2OJ/160/data/xor8.ans b/S2OJ/160/data/xor8.ans new file mode 100644 index 00000000..fe99b3c2 --- /dev/null +++ b/S2OJ/160/data/xor8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c2ecc72571e471b9d17fc064fc2fe38c706c931b56fc88841d621c0bda47508 +size 571565 diff --git a/S2OJ/160/data/xor8.in b/S2OJ/160/data/xor8.in new file mode 100644 index 00000000..c3ccc8b9 --- /dev/null +++ b/S2OJ/160/data/xor8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:600780281a3c2110c8ff967672c099e9a515a6ad51bcc7923b6406ca41f716ed +size 1951009 diff --git a/S2OJ/160/data/xor9.ans b/S2OJ/160/data/xor9.ans new file mode 100644 index 00000000..d42fd5af --- /dev/null +++ b/S2OJ/160/data/xor9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82d7df24b2d925ae1ff6ca5c407d96c35cdcb70b528b1d68724379e24d10a81c +size 950914 diff --git a/S2OJ/160/data/xor9.in b/S2OJ/160/data/xor9.in new file mode 100644 index 00000000..b2bc8ef6 --- /dev/null +++ b/S2OJ/160/data/xor9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d755d73608c51103b7410671a9424e006178471917f884a4c4729313ec5fe20 +size 3252370