#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e9+900;
bool flag(int x, int y, int z) {
cout << y - x + 1 << ' ';
for (int i = x; i < y; ++i) {
cout << i + 1 << ' ';
}
cout << z + 1 << endl;
int h1;
cin >> h1;
cout << y - x << ' ';
for (int i = x; i < y; ++i) {
cout << i + 1 << ' ';
}
int h2;
cin >> h2;
return (h1 == h2);
}
int valueof(int x, int y, int z) {
if (!flag(x, y, z)) {
return maxx;
}
while (y - x > 1) {
int m = (x + y)/2;
if (flag(x, m, z)) {
y = m;
} else {
x = m;
}
}
return x;
}
vector<int> solve(int n) {
int v = 2;
vector<int> ans;
ans.push_back(1);
for (int i = 1; i < n; ++i) {
int j = valueof(0, i, i);
if (j == maxx) {
ans.push_back(v);
v++;
} else {
ans.push_back(ans[j]);
}
}
return ans;
}
int main() {
int n;
cin >> n;
vector<int> ans = solve(n);
cout << 0 << ' ';
for (int i = 0; i < n; ++i) {
cout << ans[i] << ' ';
}
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
280 KB |
Output is correct |
2 |
Correct |
12 ms |
208 KB |
Output is correct |
3 |
Correct |
9 ms |
284 KB |
Output is correct |
4 |
Correct |
5 ms |
208 KB |
Output is correct |
5 |
Correct |
19 ms |
208 KB |
Output is correct |
6 |
Correct |
20 ms |
280 KB |
Output is correct |
7 |
Correct |
17 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
208 KB |
Output is correct |
2 |
Correct |
18 ms |
280 KB |
Output is correct |
3 |
Correct |
6 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
296 KB |
Output is correct |
5 |
Correct |
20 ms |
208 KB |
Output is correct |
6 |
Correct |
15 ms |
208 KB |
Output is correct |
7 |
Correct |
17 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
276 KB |
Output is correct |
2 |
Correct |
17 ms |
292 KB |
Output is correct |
3 |
Correct |
15 ms |
208 KB |
Output is correct |
4 |
Correct |
5 ms |
296 KB |
Output is correct |
5 |
Correct |
18 ms |
276 KB |
Output is correct |
6 |
Correct |
18 ms |
208 KB |
Output is correct |
7 |
Correct |
12 ms |
280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
276 KB |
Output is correct |
2 |
Correct |
10 ms |
208 KB |
Output is correct |
3 |
Correct |
10 ms |
300 KB |
Output is correct |
4 |
Correct |
7 ms |
208 KB |
Output is correct |
5 |
Correct |
13 ms |
276 KB |
Output is correct |
6 |
Correct |
13 ms |
208 KB |
Output is correct |
7 |
Correct |
18 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
208 KB |
Output is correct |
2 |
Correct |
23 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
208 KB |
Output is correct |
4 |
Correct |
9 ms |
284 KB |
Output is correct |
5 |
Correct |
11 ms |
208 KB |
Output is correct |
6 |
Correct |
8 ms |
296 KB |
Output is correct |
7 |
Correct |
6 ms |
300 KB |
Output is correct |