Submission #931931

#TimeUsernameProblemLanguageResultExecution timeMemory
931931OAleksaCarnival (CEOI14_carnival)C++14
100 / 100
10 ms968 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { int n; cin >> n; vector<int> vis(n), ans(n); auto Ask = [&](vector<int> s) { cout << s.size() << ' '; for (auto i : s) cout << i + 1 << ' '; cout << endl; int r; cin >> r; return r; }; vis[0] = 1; vector<int> s, c; for (int i = 0;i < n;i++) s.push_back(i); int C = Ask(s); s.clear(); c.push_back(0); vis[0] = 1; for (int i = 1;i < C;i++) { int l = 0, r = n - 1, id = -1; while (l <= r) { int mid = (l + r) / 2; s.clear(); for (auto j : c) s.push_back(j); for (int j = 0;j <= mid;j++) { if (!vis[j]) s.push_back(j); } sort(s.begin(), s.end()); if (Ask(s) > i) { r = mid - 1; id = mid; } else l = mid + 1; } assert(id != -1); vis[id] = 1; c.push_back(id); } for (int i = 0;i < C;i++) ans[c[i]] = i + 1; for (int i = 0;i < n;i++) { if (!vis[i]) { int l = 0, r = C - 1, id = -1; while (l <= r) { int mid = (l + r) / 2; vector<int> s; s.push_back(i); for (int j = 0;j <= mid;j++) s.push_back(c[j]); sort(s.begin(), s.end()); if (Ask(s) == mid + 1) { id = mid; r = mid - 1; } else l = mid + 1; } assert(id != -1); ans[i] = ans[c[id]]; } } cout << "0 "; for (int i = 0;i < n;i++) cout << ans[i] << ' '; cout << endl; } return 0; }
#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...