Submission #1042660

#TimeUsernameProblemLanguageResultExecution timeMemory
1042660RafiullahCarnival (CEOI14_carnival)C++17
0 / 100
6 ms596 KiB
#include<bits/stdc++.h> using namespace std; const int N = (1<<19); const long long mod = 1e9+7; const long long mod1 = 998244353; int query(int n,int k=-1){ int col; if(k == -1){ cout<<n<<endl; for(int i = 1;i<=n ;i ++){ cout<<i<<" "; } cout<<endl; cin >> col; } else{ cout<<n+1<<endl; for(int i = 1;i<= n; i++){ cout<<i<<" "; } cout<<k<<endl; cin >> col; } return col; } void solve(){ int n;cin >> n; vector<int> c(n+1); c[1] = 1; vector<int> q(n+1); q[1] = 1; int t = 2; for(int i = 2;i<=n ;i ++){ q[i] = query(i); int low = 1; int high = i-1; while(low<=high){ int mid = (low+high)/2; int o = query(mid,i); if(o == q[mid])high = mid-1; else low = mid+1; } if(low<i){ c[i] = c[low]; } else{ c[i] = t; t++; } } for(int i = 1;i<= n ;i++){ cout<<c[i]<<" "; } cout<<endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL); long long t=1; // cin >> t; cout<<setprecision(16); while(t--){ solve(); } }
#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...