#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
int Ask(vector<int> a) {
int x = a.size();
cout << x << sp;
for (int u : a) cout << u + 1 << sp;
cout << en;
cout.flush();
cin >> x;
return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
vector<int> p;
int pre = 0;
vector<int> tr;
vector<int> d(n, -1);
for (int i = 0; i < n; i++) {
tr.push_back(i);
int x = Ask(tr);
if (x != pre) {
d[i] = x - 1;
p.push_back(i);
}
pre = x;
}
int sz = p.size();
for (int i = 0; i < n; i++) {
if (d[i] != -1) continue;
int l = 0, r = sz - 1;
while (l < r) {
int mid = l + r >> 1;
tr.clear();
for (int j = l; j <= mid; j++) tr.push_back(p[j]);
tr.push_back(i);
int x = Ask(tr);
if (x == mid - l + 1) r = mid;
else l = mid + 1;
}
d[i] = l;
}
cout << "0 ";
for (int i = 0; i < n; i++) cout << d[i] + 1 << sp;
cout << en;
return 0;
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:41:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
41 | int mid = l + r >> 1;
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
336 KB |
Output is correct |
2 |
Correct |
7 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
324 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
4 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Output is correct |
2 |
Correct |
9 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
324 KB |
Output is correct |
5 |
Correct |
6 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
328 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
464 KB |
Output is correct |
3 |
Correct |
7 ms |
328 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
8 ms |
208 KB |
Output is correct |
6 |
Correct |
9 ms |
332 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
316 KB |
Output is correct |
3 |
Correct |
5 ms |
324 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
452 KB |
Output is correct |
6 |
Correct |
7 ms |
208 KB |
Output is correct |
7 |
Correct |
7 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
316 KB |
Output is correct |
2 |
Correct |
8 ms |
208 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
5 ms |
208 KB |
Output is correct |
5 |
Correct |
7 ms |
292 KB |
Output is correct |
6 |
Correct |
6 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |