#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<<' ';
for (int i=1;i<=n;++i) cout<<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;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
600 KB |
Integer 19 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
600 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
600 KB |
Output is correct |
2 |
Incorrect |
8 ms |
600 KB |
Integer 11 violates the range [1, 8] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
600 KB |
Integer 5 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
600 KB |
Output is correct |
2 |
Incorrect |
10 ms |
600 KB |
Integer 20 violates the range [1, 17] |
3 |
Halted |
0 ms |
0 KB |
- |