# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
709085 | Shreyan_Paliwal | Carnival (CEOI14_carnival) | C++17 | 25 ms | 208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |