Submission #709085

#TimeUsernameProblemLanguageResultExecution timeMemory
709085Shreyan_PaliwalCarnival (CEOI14_carnival)C++17
100 / 100
25 ms208 KiB
#include <bits/stdc++.h> using namespace std; int cnt = 2; int id[150]; int qry(int l, int r) { cout << r - l + 1 << ' '; for (int i = l; i <= r; i++) cout << i << ' '; cout << endl; int x; cin >> x; return x; } void guess(int n) { cout << 0 << ' '; for (int i = 0; i < n; i++) cout << id[i] << ' '; cout << endl; } int main() { int n; cin >> n; id[0] = 1; int cval = qry(1, 1); for (int i = 1; i < n; i++) { int nval = qry(1, i+1); if (nval == cval + 1) { id[i] = cnt++; } else { // binary search on rightmost leftbound int lo = 0, hi = i - 1; while (lo < hi) { int mid = (lo + hi + 1) >> 1; // range [mid to i-1] & [mid to i] are same if (qry(mid+1, i) == qry(mid+1,i+1)) { lo = mid; } else { hi = mid-1; } } id[i] = id[lo]; } cval = nval; } guess(n); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int qry(int, int)':
carnival.cpp:9:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    9 |     for (int i = l; i <= r; i++) cout << i << ' '; cout << endl;
      |     ^~~
carnival.cpp:9:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    9 |     for (int i = l; i <= r; i++) cout << i << ' '; cout << endl;
      |                                                    ^~~~
#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...