Submission #957016

#TimeUsernameProblemLanguageResultExecution timeMemory
957016pragmatistXoractive (IZhO19_xoractive)C++17
80 / 100
4 ms756 KiB
#include "interactive.h" #include <bits/stdc++.h> using namespace std; vector<int> guess(int n) { vector<int> ans(n+1, -1); map<int, int> cnt[10]; for(int i = 0; (1<<i) <= n; ++i) { vector<int> ind; for(int j = 1; j <= n; ++j) { if(j >> i & 1) { ind.push_back(j); } } assert(!ind.empty()); for(int j = 0; j < (int)ind.size(); ++j) { if(ans[ind[j]] != -1) { ind.insert(ind.begin(), ind[j]); ind.erase(ind.begin()+j+1); break; } } if(ans[ind[0]] == -1) { ans[ind[0]] = ask(ind[0]); } int st = ans[ind[0]]; if((int)ind.size()== 1) { continue; } map<int, int> cur; vector<int> c1 = get_pairwise_xor(ind); for(auto x : c1) { cur[x]++; } ind.erase(ind.begin()); if((int)ind.size() == 2) { ans[ind[0]] = (c1.back()^st); continue; } vector<int> c2 = get_pairwise_xor(ind); for(auto x : c2) { cur[x]--; } vector<int> v; for(auto e : cur) { if(e.second == 0) { continue; } v.push_back(e.first^st); } for(auto x : v) { cnt[i][x]++; } } for(int i = n; i >= 1; --i) { if(ans[i] != -1) { continue; } map<int, int> cur; int tot = 0; for(int j = 0; (1 << j) <= i; ++j) { if(i >> j & 1) { tot++; for(auto e : cnt[j]) { cur[e.first]++; } } } for(auto e : cur) { if(e.second == tot) { ans[i] = e.first; } } for(int j = 0; (1 << j) <= i; ++j) { if(i >> j & 1) { cnt[j].erase(ans[i]); } } } ans.erase(ans.begin()); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...