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 <bits/stdc++.h>
#include "interactive.h"
using namespace std;
vector<int> a[7];
set<int> s[7];
void dfs(int l, int r, int lvl){
if(r - l < 2) return;
int m = (l + r) / 2;
for(int i=l; i<m; ++i) a[lvl].push_back(i);
dfs(l, m, lvl+1);
dfs(m, r, lvl+1);
}
int find(int l, int r, int lvl, int v){
if(r - l == 1) return l;
int m = (l + r) / 2;
if(s[lvl].find(v) == s[lvl].end())
return find(m, r, lvl+1, v);
else return find(l, m, lvl+1, v);
}
vector<int> guess(int n){
int m = ask(n);
dfs(1, n, 1);
for(int i=1; i<n; ++i) a[0].push_back(i);
for(int i=0; i<7; ++i){
if(a[i].empty()) break;
vector<int> x = get_pairwise_xor(a[i]);
a[i].push_back(n);
vector<int> y = get_pairwise_xor(a[i]);
multiset<int> t;
for(int j : y) t.insert(j);
for(int j : x) t.erase(t.find(j));
for(int j : t)
if(j) s[i].insert(j ^ m);
}
vector<int> ans(n);
for(int i : s[0]) ans[find(1, n, 1, i)-1] = i;
ans[n-1] = m;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |