#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 160;
int n, s[N], c[N];
int main() {
ios :: sync_with_stdio(0); cin.tie(0);
auto ask = [&](int x, int y) {
cout << y + 1 << endl;
for (int i = 1; i <= y; ++i) cout << i << ' ';
cout << x << endl;
int z;
cin >> z;
return z;
};
cin >> n;
c[1] = ++s[1];
for (int i = 2; i <= n; ++i) {
int L = 1, R = i;
while (R - L > 1) {
int mid = L + R >> 1;
if (s[mid] != ask(i, mid)) L = mid;
else R = mid;
}
int j = (s[L] == ask(i, L) ? L : R);
s[i] = s[i - 1];
if (j == i) c[i] = ++s[i];
else c[i] = c[j];
// cout << j << endl;
}
cout << 0 << ' ';
for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:32:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
32 | int mid = L + R >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
208 KB |
Output is correct |
2 |
Correct |
15 ms |
208 KB |
Output is correct |
3 |
Correct |
15 ms |
208 KB |
Output is correct |
4 |
Correct |
15 ms |
208 KB |
Output is correct |
5 |
Correct |
10 ms |
208 KB |
Output is correct |
6 |
Correct |
11 ms |
208 KB |
Output is correct |
7 |
Correct |
9 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
208 KB |
Output is correct |
2 |
Correct |
14 ms |
208 KB |
Output is correct |
3 |
Correct |
10 ms |
208 KB |
Output is correct |
4 |
Correct |
15 ms |
208 KB |
Output is correct |
5 |
Correct |
10 ms |
208 KB |
Output is correct |
6 |
Correct |
10 ms |
208 KB |
Output is correct |
7 |
Correct |
9 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
208 KB |
Output is correct |
2 |
Correct |
7 ms |
208 KB |
Output is correct |
3 |
Correct |
19 ms |
208 KB |
Output is correct |
4 |
Correct |
16 ms |
208 KB |
Output is correct |
5 |
Correct |
11 ms |
208 KB |
Output is correct |
6 |
Correct |
11 ms |
208 KB |
Output is correct |
7 |
Correct |
11 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
15 ms |
208 KB |
Output is correct |
4 |
Correct |
15 ms |
208 KB |
Output is correct |
5 |
Correct |
11 ms |
208 KB |
Output is correct |
6 |
Correct |
12 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
208 KB |
Output is correct |
2 |
Correct |
7 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
208 KB |
Output is correct |
4 |
Correct |
14 ms |
208 KB |
Output is correct |
5 |
Correct |
12 ms |
208 KB |
Output is correct |
6 |
Correct |
13 ms |
208 KB |
Output is correct |
7 |
Correct |
14 ms |
208 KB |
Output is correct |