#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=150;
int n,ans[N+5],mp[N+5][N+5];
int Ask(int l, int r){
if (mp[l][r]) return mp[l][r];
cout<<r-l+1<<' ';
for (int i=l;i<=r;++i) cout<<i<<' ';
cout<<"\n";
fflush(stdout);
int ans;
cin>>ans;
return mp[l][r]=ans;
}
void Solve(){
cin>>n;
for (int i=1;i<=n;++i)
for (int j=1;j<=n;++j)
mp[i][j]=0;
for (int i=1;i<=n;++i) ans[i]=i;
for (int i=2;i<=n;++i){
if (Ask(1,i)!=Ask(1,i-1)) continue;
int l=1,r=i-1;
while (l<r){
int md=l+r>>1;
if (Ask(md+1,i)==Ask(md+1,i-1)) l=md+1;
else r=md;
}
ans[i]=ans[l];
}
cout<<0<<' ';
map <int,bool> mp;
map <int,int> cnt;
for (int i=1;i<=n;++i) mp[ans[i]]=true;
int idx=0;
for (pair <int,int> x : mp)
cnt[x.first]=++idx;
for (int i=1;i<=n;++i) cout<<cnt[ans[i]]<<' ';
cout<<"\n";
fflush(stdout);
}
signed main(){
int t=1;
// cin>>t;
while (t--) Solve();
}
Compilation message
carnival.cpp: In function 'void Solve()':
carnival.cpp:26:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
26 | int md=l+r>>1;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
600 KB |
Output is correct |
2 |
Correct |
7 ms |
600 KB |
Output is correct |
3 |
Correct |
5 ms |
852 KB |
Output is correct |
4 |
Correct |
3 ms |
600 KB |
Output is correct |
5 |
Correct |
9 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
600 KB |
Output is correct |
7 |
Correct |
8 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
600 KB |
Output is correct |
2 |
Correct |
9 ms |
624 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
600 KB |
Output is correct |
5 |
Correct |
11 ms |
600 KB |
Output is correct |
6 |
Correct |
10 ms |
600 KB |
Output is correct |
7 |
Correct |
8 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
600 KB |
Output is correct |
2 |
Correct |
9 ms |
600 KB |
Output is correct |
3 |
Correct |
8 ms |
600 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
7 ms |
600 KB |
Output is correct |
6 |
Correct |
7 ms |
600 KB |
Output is correct |
7 |
Correct |
8 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
600 KB |
Output is correct |
2 |
Correct |
8 ms |
600 KB |
Output is correct |
3 |
Correct |
4 ms |
600 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
624 KB |
Output is correct |
6 |
Correct |
6 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
600 KB |
Output is correct |
2 |
Correct |
13 ms |
624 KB |
Output is correct |
3 |
Correct |
7 ms |
624 KB |
Output is correct |
4 |
Correct |
5 ms |
600 KB |
Output is correct |
5 |
Correct |
5 ms |
600 KB |
Output is correct |
6 |
Correct |
5 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |