This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int n;
cin >> n;
int id[n+1];
int last = 2;
id[1] = 1;
// id[2] = 1;
// id[3] = 1;
// id[4] = 3;
// id[5] = 2;
// id[6] = 4;
for(int i = 2; i <= n; i++) {
int L = 1, R = i-1, ans = -1;
//cout << i << ":\n";
while(L <= R) {
//cout << ":::" << L << " " << R << "\n\n\n";
int mid = ceil((double) (L + R) / 2);
int with, without;
cout << R - mid + 1 << " ";
for(int j = mid; j <= R; j++) {
cout << j << " ";
}
fflush(stdout);
cin >> without;
cout << R - mid + 2 << " ";
for(int j = mid; j <= R; j++) {
cout << j << " ";
}
cout << i << " ";
fflush(stdout);
cin >> with;
if (with == without) {
ans = L;
L = mid + 1;
} else {
ans = R;
R = mid - 1;
}
}
cout << "2 " << i << " " << id[ans] << " ";
fflush(stdout);
int check;
cin >> check;
if (check == 2) {
id[i] = last++;
} else {
id[i] = id[ans];
}
}
cout << "0 ";
for(int i = 1; i <= n; i++) {
cout << id[i] << " ";
}
fflush(stdout);
return 0;
}
//~ check for overflows
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |