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 <iostream>
#include <vector>
using namespace std;
int ofcolor[151], color[151], k = 1;
bool ask(int l, int r, int i) {
cout << r - l + 2;
for (int i = l; i <= r; i++) cout << ' ' << ofcolor[i];
cout << ' ' << i << endl;
int n;
cin >> n;
return n == r - l + 1;
}
signed main() {
int n;
cin >> n;
color[1] = ofcolor[1] = 1;
for (int i = 2; i <= n; i++) {
if (!ask(1, k, i)) {
ofcolor[color[i] = ++k] = i;
continue;
}
int l = 1, r = k;
while (l < r) {
int m = l + r >> 1;
if (ask(l, m, i)) r = m;
else l = m + 1;
}
color[i] = l;
}
cout << 0;
for (int i = 1; i <= n; i++) cout << ' ' << color[i];
return 0;
}
Compilation message (stderr)
carnival.cpp: In function 'int main()':
carnival.cpp:27:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
27 | int m = l + r >> 1;
| ~~^~~
# | 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... |