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>
#define pb push_back
#define ff first
#define ss second
#define N 1000000
typedef long long ll;
using namespace std;
int color[N],k=0,p;
vector<int>v;
int interact(int l,int r,int u=0){
int y=0;
if(u!=0) y++;
cout << r-l+1+y << ' ';
for(int i=l;i<=r;i++){
cout << i << ' ';
}
if(u!=0) cout << u;
cout << endl;
cin >> p;
return p;
}
void solve(int l,int m,int r,int t){
if(l==m){
int c=interact(l,m);
int d=interact(l,m,t);
if(c==d){
color[t]=color[l];
}
else color[t]=color[l+1];
return;
}
int c=interact(l,m);
int d=interact(l,m,t);
if(c==d){
int x=(l+m)>>1;
solve(l,x,m,t);
}
else{
int x=(m+1+r)>>1;
solve(m+1,x,r,t);
}
}
int main(){
int n;
cin >> n;
color[1]=1;
k++;
for(int i=2;i<=n;i++){
int c=interact(1,i-1);
v.pb(i);
int d=interact(1,i);
if(d>c){
k++;
color[i]=k;
}
else{
int m=(1+(i-1))>>1;
solve(1,m,i-1,i);
}
}
cout << 0 << ' ';
for(int i=1;i<=n;i++){
cout << color[i] << ' ';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |