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;
#define ll long long
#define pb push_back
#define sz(x) int(x.size())
typedef pair<int,int>ii;
typedef vector<int> vi;
vi guess(int n){
vi ans;
int a0=ask(1);
multiset<int> tab[7];
for(int k=0;k<7;k++){
vi ax,ax1;
ax1.pb(1);
for(int i=1;i<n;i++){
if(i&(1<<k)){
ax.pb(i+1);
ax1.pb(i+1);
}
}
if(ax.empty())continue;
vi q=get_pairwise_xor(ax);
vi q1=get_pairwise_xor(ax1);
int i=0,i1=0;
while(!q[i])i++;
while(!q1[i1])i1++;
while(i<sz(q) && i1<sz(q1)){
if(q[i] != q1[i1]){
tab[k].insert({(q1[i1]^a0)});
i1+=2;
}
else{
i+=2;
i1+=2;
}
}
}
for(int i=n-1;i>0;i--){
vi aux;
for(int j=0;j<7;j++){
if(i&(1<<j))aux.pb(j);
}
int ini=aux[0];
for(auto it=tab[ini].begin();it!=tab[ini].end();it++){
int cur=*it;
bool ok=true;
for(int k=1;k<sz(aux);k++)if(!tab[aux[k]].count(cur)){
ok=false;
break;
}
if(ok){
ans.pb(cur);
for(int k=0;k<sz(aux);k++){
tab[aux[k]].erase(tab[aux[k]].find(cur));
}
break;
}
}
}
ans.pb(a0);
reverse(ans.begin(),ans.end());
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |