This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]){
//printf("%d %d %d\n",q.l,q.r,q.v.size());
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(int x:res){
l.v.push_back(x);res.erase(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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |