Submission #344909

#TimeUsernameProblemLanguageResultExecution timeMemory
344909IZhO_2021_I_want_SilverXoractive (IZhO19_xoractive)C++14
100 / 100
5 ms512 KiB
#include "interactive.h" #include <vector> #include <map> #define pii pair <int, int> #define F first #define S second #define pb push_back using namespace std; vector<int> guess(int n) { vector <int> ans(n); ans[0] = ask(1); map <int, int> ans_pos; for (int bit = 0; (1 << bit) <= n; ++bit) { vector <int> pos; for (int i = 2; i <= n; ++i) { if ((i >> bit) & 1) pos.pb(i); } vector <int> q1 = get_pairwise_xor(pos); pos.pb(1); vector <int> q2 = get_pairwise_xor(pos); map <int, int> cnt; for (int x : q2) ++cnt[x]; for (int x : q1) --cnt[x]; for (pii p : cnt) { if (p.F != 0 && p.S != 0) ans_pos[(p.F ^ ans[0])] += (1 << bit); } pos.clear(); q1.clear(); q2.clear(); cnt.clear(); } for (pii p : ans_pos) { ans[p.S - 1] = p.F; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...