Submission #618872

#TimeUsernameProblemLanguageResultExecution timeMemory
618872Genius3435Carnival (CEOI14_carnival)C++17
100 / 100
9 ms300 KiB
#include <bits/stdc++.h> using namespace std; constexpr int N = 256; int val[N]; vector<int> has; int query(int l, int r, int i) { cout << r-l+2; for (int j = l; j <= r; ++j) { cout << ' ' << has[j-1]; } cout << ' ' << i << '\n'; int c; cin >> c; return c; } int main() { int n; cin >> n; val[1] = 1; has.push_back(1); for (int i = 2; i <= n; ++i) { int k = has.size(); int l = 1, r = k; if (query(l,r,i) > r-l+1) { val[i] = k+1; has.push_back(i); continue; } while (l < r) { int m = l + (r-l)/2; if (query(l,m,i) == m-l+1) r = m; else l = m+1; } val[i] = l; } cout << '0'; for (int i = 1; i <= n; ++i) { cout << ' ' << val[i]; } cout << '\n'; }
#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...