Submission #918199

#TimeUsernameProblemLanguageResultExecution timeMemory
918199vjudge1Carnival (CEOI14_carnival)C++17
100 / 100
6 ms1276 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define db long double #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vii vector<pii> #define vll vector<pll> // #define endl '\n' #define all(x) x.begin(), x.end() #define fastio\ ios_base::sync_with_stdio(0);\ cin.tie(0);\ cout.tie(0)\ mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); map<vi, int> mp; int ask(vi &v){ if(mp[v]) return mp[v]; cout << v.size() << " "; for(int i : v){ cout << i << " "; } cout << endl; int x; cin >> x; return mp[v] = x; } signed main(){ int n; cin >> n; int a[n + 5], pre = 0; vi v; for(int i = 1; i <= n; i++){ v.push_back(i); int k = ask(v); if(k > pre){ a[i] = k; pre = k; } else{ v.pop_back(); int l = 0, r = v.size() - 1, ans = -1; while(l < r){ int mid = (l + r) / 2; vi tmp; for(int i = 0; i <= mid; i++){ tmp.push_back(v[i]); } int pre = ask(tmp); tmp.push_back(i); int nw = ask(tmp); if(nw == pre){ r = mid; } else{ l = mid + 1; } } a[i] = a[v[l]]; } } cout << 0 << " "; for(int i = 1; i <= n; i++){ cout << a[i] << " "; } cout << endl; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:51:42: warning: unused variable 'ans' [-Wunused-variable]
   51 |             int l = 0, r = v.size() - 1, ans = -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...