# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131847 | shafinalam | Carnival (CEOI14_carnival) | C++14 | 9 ms | 376 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 <bits/stdc++.h>
using namespace std;
int ans[1000];
int query(vector<int>v)
{
int sz = v.size();
cout << sz;
for(int i : v) cout << ' ' << i;
cout << endl;
int x;
cin >> x;
return x;
}
int main()
{
int n;
cin >> n;
vector<int>arr;
arr.push_back(1);
for(int i = 2; i <= n; i++)
{
vector<int>tmp = arr;
tmp.push_back(i);
if(query(tmp)==tmp.size()) arr = tmp;
}
for(int i = 0; i < arr.size(); i++) ans[arr[i]] = i+1;
for(int i = 1; i <= n; i++)
{
if(ans[i]) continue;
int lo = 0, hi = arr.size()-1, indx;
while(lo<=hi)
{
int mid = (lo+hi)>>1;
vector<int>tmp;
tmp.push_back(i);
for(int r = 0; r < mid; r++) tmp.push_back(arr[r]);
if(query(tmp)==mid)
{
indx = mid-1;
hi = mid-1;
}
else lo = mid+1;
}
ans[i] = ans[arr[indx]];
}
cout << 0;
for(int i = 1; i <= n; i++) cout << " " << ans[i];
cout << endl;
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... |