Submission #908419

#TimeUsernameProblemLanguageResultExecution timeMemory
90841912345678Carnival (CEOI14_carnival)C++17
100 / 100
11 ms720 KiB
#include <bits/stdc++.h> using namespace std; const int nx=155; int n, ans[nx], res, cnt; int query(vector<int> v) { if (v.size()==1) return 1; cout<<v.size()<<' '; for (auto x:v) cout<<x<<' '; cout<<endl; cin>>res; return res; } int in(int idx, int l, int r) { if (r<l) return 0; vector<int> qrs; for (int i=l; i<=r; i++) qrs.push_back(i); auto sv=query(qrs); qrs.push_back(idx); auto nw=query(qrs); return sv==nw; } int search(int idx, int l, int r) { if (l==r) return l; int md=(l+r)/2; if (in(idx, l, md)) return search(idx, l, md); else return search(idx, md+1, r); } int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) { if (!in(i, i+1, n)) { if (ans[i]==0) ans[i]=++cnt; } else { int vl=search(i, i+1, n); if (!ans[i]) ans[i]=++cnt, ans[vl]=ans[i]; else ans[vl]=ans[i]; } } cout<<0<<' '; for (int i=1; i<=n; i++) cout<<ans[i]<<' '; return 0; }
#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...