Submission #402801

#TimeUsernameProblemLanguageResultExecution timeMemory
402801jamezzzXoractive (IZhO19_xoractive)C++14
100 / 100
9 ms524 KiB
#include "interactive.h" #include <bits/stdc++.h> using namespace std; int val; set<int> get(vector<int> v){ multiset<int> ms; set<int> res; v.push_back(1); for(int x:get_pairwise_xor(v)){ ms.insert(x); } v.pop_back(); for(int x:get_pairwise_xor(v)){ if(ms.count(x)){ ms.erase(ms.find(x)); } } for(auto it:ms){ if((it^val)==val)continue; res.insert(it^val); } return res; } struct qry{ int l,r; vector<int> v; }; vector<int> ans; vector<qry> v[2]; vector<int> guess(int n){ ans.resize(n); val=ask(1); ans[0]=val; int f=0; bool done=false; v[f].push_back({2,n}); while(true){ vector<int> ask; for(qry &q:v[f]){ if(q.l==q.r&&q.v.size()!=0){ ans[q.l-1]=q.v[0]; continue; } for(int i=q.l;i<=(q.l+q.r)/2;++i)ask.push_back(i); } if(ask.size()==0)break; set<int> res=get(ask); for(qry &q:v[f]){ if(q.v.size()==0){ qry l={q.l,(q.l+q.r)/2},r={(q.l+q.r)/2+1,q.r}; for(auto x:res){ l.v.push_back(x); } if(l.l<=l.r)v[1-f].push_back(l); if(q.l!=q.r)v[1-f].push_back(r); } else{ if(q.l==q.r&&q.v.size()!=0)continue; qry l={q.l,(q.l+q.r)/2},r={(q.l+q.r)/2+1,q.r}; for(int x:q.v){ if(res.find(x)!=res.end())l.v.push_back(x),res.erase(x); else r.v.push_back(x); } if(l.l<=l.r)v[1-f].push_back(l); if(r.l<=r.r)v[1-f].push_back(r); } } v[f].clear(); f=1-f; } f=1-f; return ans; }

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:40:7: warning: unused variable 'done' [-Wunused-variable]
   40 |  bool done=false;
      |       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...