Submission #585880

#TimeUsernameProblemLanguageResultExecution timeMemory
585880stevancvCarnival (CEOI14_carnival)C++14
100 / 100
9 ms464 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; int Ask(vector<int> a) { int x = a.size(); cout << x << sp; for (int u : a) cout << u + 1 << sp; cout << en; cout.flush(); cin >> x; return x; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> p; int pre = 0; vector<int> tr; vector<int> d(n, -1); for (int i = 0; i < n; i++) { tr.push_back(i); int x = Ask(tr); if (x != pre) { d[i] = x - 1; p.push_back(i); } pre = x; } int sz = p.size(); for (int i = 0; i < n; i++) { if (d[i] != -1) continue; int l = 0, r = sz - 1; while (l < r) { int mid = l + r >> 1; tr.clear(); for (int j = l; j <= mid; j++) tr.push_back(p[j]); tr.push_back(i); int x = Ask(tr); if (x == mid - l + 1) r = mid; else l = mid + 1; } d[i] = l; } cout << "0 "; for (int i = 0; i < n; i++) cout << d[i] + 1 << sp; cout << en; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:41:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |             int mid = l + r >> 1;
      |                       ~~^~~
#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...