Submission #898930

#TimeUsernameProblemLanguageResultExecution timeMemory
898930vjudge1Xoractive (IZhO19_xoractive)C++17
0 / 100
1 ms344 KiB
#include "interactive.h" #include "bits/stdc++.h" using namespace std; #define all(x) x.begin(), x.end() const int N = 6; int mask[N]; void init() { int curr = 0; int x = 0; for (int i = 0; i < 4; i++) { x ^= (1 << i); for (int j = i+1; j < 4; j++) { x ^= (1 << j); mask[curr++] = x; x ^= (1 << j); } x ^= (1 << i); } } vector<int> guess(int n) { init(); vector <int> ans(n+1); ans[1] = ask(1); for (int i = 1; i <= n; i++) { if (i == n) break; // [i, i+3] vector<int> query; for (int j = i; j <= min(n, i+3); j++) { query.push_back(j); } int sz = query.size(); vector<int> px = get_pairwise_xor(query); sort(all(px)); vector<int> npx; for (int j = sz; j < sz*sz; j+=2) { npx.push_back(px[j]); } do { vector<int> val((1 << sz), -1); bool ok = 1; int nwSz = sz*(sz-1)/2; for (int j = 0; j < (1 << nwSz); j++) { int x = 0; int y = 0; for (int k = 0; k < nwSz; k++) { if ((j >> k) & 1) { x ^= mask[k]; y ^= npx[k]; } } if (val[x] == -1) val[x] = y; else if (val[x] != y) { ok = 0; break; } } if (ok) break; } while (next_permutation(all(npx))); for (int j = i+1; j <= min(n, i+3); j++) { ans[j] = npx[j - i+1] ^ ans[i]; } i = i+3 - 1; } ans.erase(ans.begin()); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...