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;
vector<int> guess(int n) {
vector<int> ans(n);
ans[0] = ask(1);
map<int, int> ocurrences;
for(int b = 6; b >= 0; b--){
vector<int> pos;
for(int i = 1; i < n; i++){
if((1 << b) & i) pos.push_back(i+1);
}
if(pos.empty()) continue;
vector<int> ans1 = get_pairwise_xor(pos);
pos.push_back(1);
vector<int> ans2 = get_pairwise_xor(pos);
map<int, int> mp;
for(int x : ans2) mp[x]++;
for(int x : ans1){
mp[x]--;
if(!mp[x]) mp.erase(x);
}
for(pair<int, int> p : mp){
if(!p.first) continue;
ocurrences[(p.first ^ ans[0])] += (1 << b);
}
}
for(int i = 1; i < n; i++){
for(pair<int, int> p : ocurrences){
if(p.second == i){
ans[i] = p.first;
break;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |