Submission #743428

#TimeUsernameProblemLanguageResultExecution timeMemory
743428NintsiChkhaidzeCarnival (CEOI14_carnival)C++17
100 / 100
10 ms328 KiB
#include <bits/stdc++.h> #define ll long long #define s second #define pb push_back #define f first using namespace std; const int N = 205; int a[N],c[N],arr[N]; bool f[N]; int query(int l,int r,int x){ cout<<r - l + 2<<" "; for (int i = l; i <= r; i++) cout<<a[i]<<" "; cout<<x<<endl; int k; cin>>k; return k; } signed main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n; cin>>n; int m = 1; a[1] = 1; f[1] = 1; for (int i = 2; i <= n; i++){ int k = query(1,m,i); if (k == m + 1){ ++m; a[m] = i; f[i] = 1; } } for (int i = 1; i <= m; i++) c[a[i]] = i; for (int i = 1; i <= n; i++){ if (f[i]) continue; int res=0,l = 1,r = m; while (l <= r){ int mid = (l + r)>>1; int k = query(l,mid,i); if (l == r && k == 1) { res = l; break; } if (k == mid - l + 2){ l = mid + 1; }else{ r = mid; } } c[i] = c[a[res]]; } cout<<0<<" "; for (int i = 1; i <= n; i++) cout<<c[i]<<" "; cout<<endl; }
#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...