# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116775 | 2019-06-13T19:53:34 Z | ioilolcom | Carnival (CEOI14_carnival) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int ll; const int N=125; int P[N],ans[N]; int cnt=0; int ask(int P, int extra = -1) { if (extra <= P) { cout << P << " "; for (int i = 1; i <= P; i++) cout << i << " "; cout << endl; fflush(stdout); } else { cout << P + 1 << " "; for (int i = 1; i <= P; i++) cout << i << " "; cout << extra << endl; fflush(stdout); } int rtn; cin >> rtn; return rtn; } int main() { int n; cin>>n; for(int i=1; i<=n; i++) { P[i]=query(i,0); } int nxt = 1; for (int i = 1; i <= n; i++) { int lo = 1, hi = i, mid; while (lo < hi) { mid = (lo + hi) / 2; if (P[mid] == query(mid, i)) hi = mid; else lo = mid + 1; } if (i == lo) ans[i] = nxt++; else ans[i] = ans[lo]; } cout<<0<<" "; for(int i=1; i<=n; i++) { cout<<ans[i]<<" "; } cout<<endl; return 0; }