#include "bits/stdc++.h"
#include "interactive.h"
using namespace std;
const int maxn=105;
int a[maxn];
int lft[4*maxn],rgt[4*maxn];
set<int>arr[4*maxn];
vector<int>fn;
map<int,vector<int>>m;
void f(int l,int r,int nd,int lev){
lft[nd] = l;
rgt[nd] = r;
m[lev].push_back(nd);
if(l == r){
fn.push_back(nd);
return;
}
int md = (l + r) / 2;
f(l,md,nd*2,lev+1);
f(md+1,r,nd*2+1,lev+1);
}
set<int>A(vector<int>v){
if(v.empty()) return set<int>();
vector<int>now = v;
now.push_back(1);
vector<int>nw = get_pairwise_xor(now);
vector<int>z = get_pairwise_xor(v);
multiset<int>SS(nw.begin(),nw.end());
for(auto i : z) SS.erase(SS.find(i));
set<int>jg;
for(auto i : SS) jg.insert(i ^ a[1]);
jg.erase(a[1]);
return jg;
}
vector<int> guess(int n) {
a[1] = ask(1);
f(2,n,1,1);
vector<int>go;
for(int i = 2;i <= n;i++) go.push_back(i);
arr[1] = A(go);
assert(m.size() <= 7);
for(auto i : m){
if(i.first == 1) continue;
vector<int>now;
for(auto j : i.second){
if(!(j & 1)) for(int k = lft[j];k <= rgt[j];k++){
now.push_back(k);
}
}
set<int>sw = A(now);
for(auto j : i.second){
if(j & 1){
arr[j] = arr[(j-1)/2];
for(auto l : arr[j-1]) arr[j].erase(l);
}
else {
for(auto l : arr[j/2]) if(sw.find(l) != sw.end()) arr[j].insert(l);
}
}
}
vector<int>ans; ans.push_back(a[1]);
for(auto i : fn){
if(!arr[i].empty()) ans.push_back(*arr[i].begin());
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1608 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |