Submission #995870

#TimeUsernameProblemLanguageResultExecution timeMemory
995870vjudge1Carnival (CEOI14_carnival)C++17
100 / 100
5 ms600 KiB
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll,ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 1e9+7; const ll inf = 1e18; const ll base = 31; const ll blocksz = 320; const ll N = 2e5+8; const ll buff = 1e5+1; ll a[N],n; ll ask(vi a){ cout << a.size() << " "; for(ll i:a) cout << i << " "; cout << endl; ll res;cin >> res; return res; } void solve(){ cin >> n; vector<ll> ind; a[1] = 1; ind.pb(1); ll cntcol = 1; for(ll i = 2; i <= n; i++){ vi qr = ind; qr.pb(i); ll c = ask(qr); if(c == cntcol+1){ a[i] = ++cntcol; ind.pb(i); } else{ ll l = 0, r = (ll)ind.size()-1; while(l < r){ ll m = l+r>>1; qr.clear(); for(ll j = l; j <= m; j++) qr.pb(ind[j]); qr.pb(i); c = ask(qr); if(c == m-l+2){ l = m+1; } else r = m; } a[i] = a[ind[r]]; } } cout << "0 "; for(ll i = 1; i <= n; i++) cout << a[i] << " "; } signed main(){ // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // if(fopen("test.inp","r")){ // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); // } ll T = 1; // cin >> T; for(ll i = 1; i <= T; i++){ solve(); if(i < T) cout << '\n'; } }

Compilation message (stderr)

carnival.cpp: In function 'void solve()':
carnival.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |                 ll m = 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...