# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
713838 | Pacybwoah | Xoractive (IZhO19_xoractive) | C++14 | 0 ms | 0 KiB |
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<vector>
#include<map>
#include<algorithm>
using namespace std;
vector<int> guess(int n) {
vector <int> ans(n);
int one=ask(1);
vector<vector<int>> bitxor(7),askans(7),noone(7);
for(int i=1;i<=n;i++){
for(int j=0;j<7;j++){
if(i&(i<<j)) bitxor[j].push_back(i);
}
}
for(int i=0;i<7;i++){
askans[i]=get_pairwise_xor(bitxor[i]);
bitxor[i].erase(bitxor.begin());
noone[i]=get_pairwise_xor(bitxor[i]);
for(int j=0;j<noone[i].size();j++){
askans[i].erase(find(askans[i].begin(),askans[i].end(),noone[i][j]));
}
while(*askans[i].begin()==0) askans[i].erase(askans[i].begin());
}
map<int,int> m;
for(int i=0;i<7;i++){
for(int j=0;j<askans[i].size();j++){
askans[i][j]^=one;
m[askans[i][j]]+=(1<<i);
}
}
ans[0]=one;
for(auto x:m){
ans[x.second-1]=x.first;
}
return ans;
}