Submission #762007

#TimeUsernameProblemLanguageResultExecution timeMemory
762007NK_Xoractive (IZhO19_xoractive)C++17
100 / 100
5 ms444 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> #include "interactive.h" using namespace std; #define nl '\n' #define pb push_back template<class T> using V = vector<T>; V<int> sub(V<int> A, V<int> B){ unordered_map<int, int> C; for(auto& v : A) C[v]++; for(auto& v : B) C[v]--; V<int> RES; for(auto p : C) for(int t = 0; t < p.second; t++) RES.push_back(p.first); return RES; } V<int> add(V<int> A, V<int> B){ unordered_map<int, int> C; for(auto& v : A) C[v]++; for(auto& v : B) C[v]++; V<int> RES; for(auto p : C) for(int t = 0; t < p.second; t++) RES.push_back(p.first); return RES; } const int LG = 7; V<int> guess(int N) { V<int> ans(N); auto XOR = [&](int x, bool IN) { V<int> idx; for(int i = 0; i < N; i++) if ((i >> x) & 1) idx.pb(i + 1); if (IN) idx.pb(1); if (size(idx) <= 1) return V<int>(); V<int> K = get_pairwise_xor(idx); unordered_map<int, int> C; for(auto& v : K) C[v]++; V<int> RES; for(auto p : C) if (p.first != 0) { for(int t = 0; t < p.second / 2; t++) RES.push_back(p.first); } return RES; }; auto ASK = [&](int x) { return ask(x + 1); }; V<V<int>> R(LG), L(LG), D(LG); V<int> ALL; for(int b = 0; b < LG; b++) { R[b] = sub(XOR(b, 1), XOR(b, 0)); } for(int b = LG - 1; b >= 1; b--) { D[b] = add(R[b], L[b]); L[b - 1] = sub(D[b], R[b - 1]); } ALL = add(L[0], R[0]); ans[0] = ASK(0); for(auto& x : ALL) { int pos = 0; for(int i = 0; i < LG; i++) if (find(begin(R[i]), end(R[i]), x) != end(R[i])) { pos ^= (1 << i); } ans[pos] = x ^ ans[0]; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...