#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
492 KB |
Output is correct |
2 |
Correct |
18 ms |
364 KB |
Output is correct |
3 |
Correct |
9 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
29 ms |
364 KB |
Output is correct |
6 |
Correct |
33 ms |
384 KB |
Output is correct |
7 |
Correct |
24 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
384 KB |
Output is correct |
2 |
Correct |
27 ms |
364 KB |
Output is correct |
3 |
Correct |
10 ms |
364 KB |
Output is correct |
4 |
Correct |
8 ms |
492 KB |
Output is correct |
5 |
Correct |
20 ms |
364 KB |
Output is correct |
6 |
Correct |
21 ms |
364 KB |
Output is correct |
7 |
Correct |
23 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
492 KB |
Output is correct |
2 |
Correct |
30 ms |
364 KB |
Output is correct |
3 |
Correct |
18 ms |
364 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
20 ms |
384 KB |
Output is correct |
6 |
Correct |
20 ms |
364 KB |
Output is correct |
7 |
Correct |
14 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
364 KB |
Output is correct |
2 |
Correct |
32 ms |
364 KB |
Output is correct |
3 |
Correct |
15 ms |
364 KB |
Output is correct |
4 |
Correct |
6 ms |
364 KB |
Output is correct |
5 |
Correct |
25 ms |
364 KB |
Output is correct |
6 |
Correct |
17 ms |
364 KB |
Output is correct |
7 |
Correct |
24 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
364 KB |
Output is correct |
2 |
Correct |
22 ms |
364 KB |
Output is correct |
3 |
Correct |
14 ms |
492 KB |
Output is correct |
4 |
Correct |
13 ms |
364 KB |
Output is correct |
5 |
Correct |
13 ms |
364 KB |
Output is correct |
6 |
Correct |
10 ms |
364 KB |
Output is correct |
7 |
Correct |
9 ms |
364 KB |
Output is correct |