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 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 (stderr)
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 |
---|
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... |