Submission #954935

#TimeUsernameProblemLanguageResultExecution timeMemory
954935esomerXoractive (IZhO19_xoractive)C++17
100 / 100
5 ms680 KiB
#include "interactive.h" #include <bits/stdc++.h> using namespace std; vector<int> guess(int n) { vector<int> ans(n); ans[0] = ask(1); map<int, int> ocurrences; for(int b = 6; b >= 0; b--){ vector<int> pos; for(int i = 1; i < n; i++){ if((1 << b) & i) pos.push_back(i+1); } if(pos.empty()) continue; vector<int> ans1 = get_pairwise_xor(pos); pos.push_back(1); vector<int> ans2 = get_pairwise_xor(pos); map<int, int> mp; for(int x : ans2) mp[x]++; for(int x : ans1){ mp[x]--; if(!mp[x]) mp.erase(x); } for(pair<int, int> p : mp){ if(!p.first) continue; ocurrences[(p.first ^ ans[0])] += (1 << b); } } for(int i = 1; i < n; i++){ for(pair<int, int> p : ocurrences){ if(p.second == i){ ans[i] = p.first; break; } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...