Submission #923520

#TimeUsernameProblemLanguageResultExecution timeMemory
923520rolandpetreanCarnival (CEOI14_carnival)C++17
100 / 100
13 ms944 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; // #define int ll //#define endl '\n' #define pb push_back using pi = pair<int, int>; int ask(vector<int> a) { cout << a.size() << " "; for (int i : a) cout << i << " "; cout << endl; int ans; cin >> ans; return ans; } int ask(int st, int dr) { vector<int> a; for (int i = st; i <= dr; ++i) a.pb(i); return ask(a); } int32_t main() { //ios_base::sync_with_stdio(false); //cin.tie(NULL); int n; cin >> n; int C = 0; vector<int> a(n + 1), pref(n + 1); for (int i = 1; i <= n; ++i) pref[i] = ask(1, i); for (int i = 1; i <= n; ++i) { if (pref[i] > pref[i - 1]) { a[i] = ++C; continue; } int st = 1, dr = i - 1, res = dr; while (st <= dr) { int mid = (st + dr) / 2; if (ask(mid, i) == ask(mid, i - 1)) { res = mid; st = mid + 1; } else dr = mid - 1; } a[i] = a[res]; } cout << "0 "; for (int i = 1; i <= n; ++i) cout << a[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...