Submission #1132559

#TimeUsernameProblemLanguageResultExecution timeMemory
1132559lopkusCarnival (CEOI14_carnival)C++20
100 / 100
9 ms472 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int ask(int k, vector<int> V) { cout << k << " "; for(auto it : V) { cout << it << " "; } cout << endl; int x; cin >> x; return x; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> ans(n + 1, 0); int current = 1; vector<int> next(n + 1, -1); vector<int> was(n + 1, 0); for(int i = 1; i <= n; i++) { int l = i + 1, r = n, p = - 1; while(l <= r) { int mid = (l + r) / 2; vector<int> v1, v2; for(int j = i; j <= mid; j++) { v1.push_back(j); } for(int j = i + 1; j <= mid; j++) { v2.push_back(j); } int x = ask(v1.size(), v1); int y = ask(v2.size(), v2); if(x == y) { r = mid - 1; p = mid; } else { l = mid + 1; } } next[i] = p; if(p == - 1) { // this is special color } } for(int i = 1; i <= n; i++) { if(was[i]) { continue; } int position = i; while(position != - 1) { was[position] = 1; ans[position] = current; position = next[position]; } current += 1; } cout << "0 "; for(int i = 1; i <= n; i++) { cout << ans[i] << " "; } }
#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...