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 ask(vector<int> v) {
cout << v.size() << " ";
for(int &x : v) cout << x << " ";
cout << endl;
int x;
cin >> x;
return x;
}
int main() {
int n;
cin >> n;
vector<int> ans(n+1), ok(n+1);
ans[1] = ok[1] = 1;
int cnt = 1;
vector<int> v = { 1 };
for(int i=2; i<=n; i++) {
v.push_back(i);
int X = ask(v);
if(X == cnt + 1) {
ans[i] = ++cnt;
continue;
}
int l=0, r=v.size()-2;
while(l <= r) {
int mid = (l + r) / 2;
vector<int> v2;
for(int j=l; j<=mid; j++) v2.push_back(v[j]);
if(ask(v2) == mid - l + 1) ans[i] = ans[v[mid]], r = mid - 1;
else l = mid + 1;
}
v.pop_back();
}
for(int &x : ans) cout << x << " ";
cout << endl;
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... |