Submission #995898

#TimeUsernameProblemLanguageResultExecution timeMemory
995898kustizusCarnival (CEOI14_carnival)C++17
100 / 100
14 ms856 KiB
#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 (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...