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;
int query1(int l, int r, int cur) {
cout << r - l + 2 << " ";
for(int i = l; i <= r; ++i) cout << i << " ";
cout << cur << endl;
int res;
cin >> res;
return res;
}
int query2(int l, int r) {
cout << r - l + 1 << " ";
for(int i = l; i <= r; ++i) cout << i << " ";
cout << endl;
int res;
cin >> res;
return res;
}
void solve() {
int n;
cin >> n;
vector<int> ans(1 + n, 0);
vector<int> prefDiffNum(1 + n, 0);
for(int i = 1; i <= n; ++i) {
prefDiffNum[i] = query2(1, i);
}
int curCnt = 0;
for(int i = 1; i <= n; ++i) {
if(prefDiffNum[i] != prefDiffNum[i - 1]) {
++curCnt;
ans[i] = curCnt;
} else {
int l = 1, r = i;
while(l < r - 1) {
int mid = (l + r) / 2;
int a = query1(mid, r - 1, i);
int b = query2(mid, r - 1);
if(a == b) {
l = mid;
} else {
r = mid;
}
}
ans[i] = ans[l];
}
}
cout << "0 ";
for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
cout << endl;
}
int main() {
solve();
return 0;
}
# | 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... |