Submission #954668

#TimeUsernameProblemLanguageResultExecution timeMemory
954668SharkyXoractive (IZhO19_xoractive)C++17
100 / 100
4 ms600 KiB
#include <bits/stdc++.h> #include "interactive.h" using namespace std; vector<int> query(vector<int>& v) { if (v.empty()) return vector<int> {}; return get_pairwise_xor(v); } vector<int> guess(int n) { vector<int> disc, ans(n, 0); vector<set<int>> layer(7); int a0 = ask(1); for (int i = 0; i <= 6; i++) { vector<int> s, a, b; for (int j = 2; j <= n; j++) { if (j & (1 << i)) s.push_back(j); } a = query(s); s.push_back(1); b = query(s); for (int x : a) { for (int j = 0; j < (int) b.size(); j++) { if (b[j] == x) { b.erase(b.begin() + j); break; } } } for (int x : b) { disc.push_back(x ^ a0); layer[i].insert(x ^ a0); } } sort(disc.begin(), disc.end()); disc.erase(unique(disc.begin(), disc.end()), disc.end()); ans[0] = a0; for (int x : disc) { if (x == a0) continue; int pos = 0; for (int i = 0; i <= 6; i++) if (layer[i].count(x)) pos += (1 << i); ans[pos - 1] = x; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...