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> poz;
for(int bit = 0;bit<7;bit++){
vector<int> toask;
for(int i=2;i<=n;i++){
if(i & (1<<bit))
toask.push_back(i);
}
if(toask.size()){
vector<int> fans = get_pairwise_xor(toask);
map<int,int> frv;
for(auto x:fans)
if(x){
frv[x] ++;
}
toask.push_back(1);
vector<int> sans = get_pairwise_xor(toask);
for(auto x:sans){
if(x){
if(frv.count(x) && frv[x] > 0)
frv[x]--;
else
poz[x^ans[0]] |= ( 1<< bit);
}
}
}
}
for(auto x:poz){
ans[x.second - 1] = x.first;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |