Submission #709972

#TimeUsernameProblemLanguageResultExecution timeMemory
709972TranGiaHuy1508Carnival (CEOI14_carnival)C++17
0 / 100
8 ms300 KiB
#include <bits/stdc++.h> using namespace std; void main_program(); signed main(){ main_program(); } int ask(vector<int> &V){ if (V.empty()) return 0; cout << V.size(); for (auto i: V) cout << " " << i+1; cout << "\n"; cout.flush(); int res; cin >> res; return res; } void main_program(){ int n; cin >> n; int prev = 0; vector<int> query = {}; vector<int> f = {}; for (int i = 0; i < n; i++){ query.push_back(i); int val = ask(query); if (val > prev){ f.push_back(i); prev = val; } } vector<int> arrow(n, -2); for (auto i: f) arrow[i] = -1; for (int i = 0; i < n; i++){ if (arrow[i] != -2) continue; int l = 0, r = f.size() - 1; while (l < r){ int mid = (l + r) >> 1; vector<int> query2; for (int j = 0; j <= mid; j++) query2.push_back(f[j]); query2.push_back(i); sort(query2.begin(), query2.end()); if (ask(query2) == (int)query2.size()) l = mid+1; else r = mid; } arrow[i] = l; } vector<int> num(n, 0); for (int i = 0; i < (int)f.size(); i++) num[f[i]] = i+1; for (int i = 0; i < n; i++){ if (!num[i]) num[i] = num[arrow[i]]; } cout << 0; for (int i = 0; i < n; i++) cout << " " << num[i]; cout << "\n"; cout.flush(); }
#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...