# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422483 | snasibov05 | Carnival (CEOI14_carnival) | C++14 | 17 ms | 328 KiB |
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 <iostream>
#include <vector>
using namespace std;
#define pb push_back
int ask(vector<int> v){
cout << v.size() << " ";
for (auto x : v) cout << x << " ";
cout << endl;
int res; cin >> res;
return res;
}
void answer(vector<int> ans){
int n = ans.size() - 1;
cout << "0 ";
for (int i = 1; i <= n; ++i){
cout << ans[i] << " ";
}
cout << "\n";
}
int main() {
int n; cin >> n;
vector<int> ans(n+1);
ans[1] = 1;
vector<int> unique;
unique.pb(1);
for (int i = 2; i <= n; ++i){
vector<int> v;
for (auto x : unique) v.pb(x);
v.pb(i);
int k = ask(v);
if (k == unique.size() + 1){
ans[i] = ans[unique.back()] + 1;
unique.pb(i);
continue;
}
int l = 0, r = unique.size() - 1;
while (l < r){
int m = (l + r) / 2;
v.clear();
for (int j = l; j <= m; ++j) {
v.pb(unique[j]);
}
v.pb(i);
k = ask(v);
if (k == m - l + 1) r = m;
else l = m+1;
}
ans[i] = ans[unique[l]];
}
answer(ans);
return 0;
}
Compilation message (stderr)
# | 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... |