#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using std::cout;
using std::cin;
vector <int> dsu_arr;
const int dsu_parent (int p) {
return (dsu_arr[p] == p ? p : dsu_arr[p] = dsu_parent (dsu_arr[p]));
}
inline void dsu_join (int a, int b) {
a = dsu_parent (a), b = dsu_parent (b);
if (a != b)
dsu_arr[b] = a;
}
inline const bool check (int I, int L, int R) {
if (L == R) {
cout << 2 << ' ' << I << ' ' << L << '\n';
cout.flush ();
int out = 0;
cin >> out;
if (out == 1)
return 1;
return 0;
}
cout << R - L + 1 << ' ';
for (int i = L; i <= R; i++)
cout << i << ' ';
cout << '\n';
cout.flush();
int out1 = 0;
cin >> out1;
cout << R - L + 2 << ' ';
for (int i = L; i <= R; i++)
cout << i << ' ';
cout << I << '\n';
cout.flush();
int out2 = 0;
cin >> out2;
if (out1 == out2)
return true;
return false;
}
int main () {
int n = 0;
cin >> n;
dsu_arr.resize (n + 1);
for (int i = 1; i <= n; i++)
dsu_arr[i] = i;
for (int i = 1; i <= n; i++) {
int L = i + 1, R = n;
int ans = -1;
while (L <= R) {
int mid = (L + R) / 2;
if (check (i, L, mid)) {
R = mid - 1;
ans = mid;
} else
L = mid + 1;
}
// cout << '\t' << i << ' ' << ans << '\n';
if (ans != -1)
dsu_join (i, ans);
}
cout << 0 << ' ';
int free = 1;
vector <int> v (n + 1, -1);
for (int i = 1; i <= n; i++) {
if (v[dsu_parent (i)] == -1)
v[dsu_parent (i)] = free, free++;
cout << v[dsu_parent (i)] << ' ';
}
cout.flush();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
10 ms |
344 KB |
Output is correct |
4 |
Correct |
7 ms |
344 KB |
Output is correct |
5 |
Correct |
9 ms |
344 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
7 ms |
344 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
10 ms |
344 KB |
Output is correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
8 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
8 ms |
344 KB |
Output is correct |
4 |
Correct |
8 ms |
344 KB |
Output is correct |
5 |
Correct |
7 ms |
344 KB |
Output is correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
9 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
344 KB |
Output is correct |
2 |
Correct |
10 ms |
344 KB |
Output is correct |
3 |
Correct |
11 ms |
344 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
9 ms |
344 KB |
Output is correct |
6 |
Correct |
8 ms |
344 KB |
Output is correct |
7 |
Correct |
8 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
344 KB |
Output is correct |
3 |
Correct |
9 ms |
344 KB |
Output is correct |
4 |
Correct |
12 ms |
344 KB |
Output is correct |
5 |
Correct |
7 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
344 KB |
Output is correct |
7 |
Correct |
9 ms |
344 KB |
Output is correct |