Submission #987207

#TimeUsernameProblemLanguageResultExecution timeMemory
987207VMaksimoski008Carnival (CEOI14_carnival)C++17
0 / 100
6 ms952 KiB
#include <bits/stdc++.h> using namespace std; int ask(vector<int> v) { cout << v.size() << " "; for(int &x : v) cout << x << " "; cout << endl; int x; cin >> x; return x; } void find(int n) { vector<int> ans(n+1); ans[1] = 1; int cnt = 1; vector<int> v = { 1 }; for(int i=2; i<=n; i++) { v.push_back(i); int X = ask(v); if(X > cnt) { ans[i] = ++cnt; continue; } int l=1, r=i-1; while(l <= r) { int mid = (l + r) / 2; vector<int> v2; for(int j=1; j<=mid; j++) v2.push_back(j); v2.push_back(i); if(ask(v2) >= X) ans[i] = ans[mid], r = mid - 1; else l = mid + 1; } } for(int &x : ans) cout << x << " "; cout << endl; return ; } int main() { int n; cin >> n; find(n); 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...