#include <bits/stdc++.h>
using namespace std;
vector<int> group[200];
int check(int x, int y, int test) {
cout << y - x + 2 << ' ' << test << ' ';
for (int i = x; i <= y; i++) {
cout << group[i][0] << ' ';
}
cout << endl;
int res; cin >> res;
return res != y - x + 1;
}
int main() {
int N; cin >> N;
int cnt = 1;
group[1].push_back(1);
for (int i = 2; i <= N; ++i) {
if (check(1, cnt, i)) {
group[++cnt].push_back(i);
continue;
}
int l = 1, r = cnt - 1;
while(l <= r) {
int m = l + r >> 1;
if (check(l, m, i)) l = m + 1;
else r = m - 1;
}
group[l].push_back(i);
}
int ans[200];
for (int i = 1; i <= cnt; i++) {
for (int k : group[i]) ans[k] = i;
}
cout << "0 ";
for (int i = 1; i <= N; i++) cout << ans[i] << ' ';
cout << endl;
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:35:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
35 | int m = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
300 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Output is correct |
2 |
Correct |
7 ms |
300 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
304 KB |
Output is correct |
5 |
Correct |
4 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
8 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
300 KB |
Output is correct |
7 |
Correct |
7 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Output is correct |
2 |
Correct |
5 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
208 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
8 ms |
300 KB |
Output is correct |
4 |
Correct |
6 ms |
304 KB |
Output is correct |
5 |
Correct |
5 ms |
304 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |