# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085608 | vjudge1 | Carnival (CEOI14_carnival) | C++17 | 5 ms | 484 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;
#define ld long double
#define int long long
#define ar array
const int N = 1e6 + 20;
int ask(vector<int> &v){
cout<<v.size()<<" ";
for(auto u: v)cout<<u<<" ";
cout<<endl;
int x;
cin>>x;
return x;
}
bool in(vector<int> v,int x){
v.push_back(x);
return ask(v) == (v.size() - 1);
}
signed main() {ios_base::sync_with_stdio(false);cin.tie(0);
int n;
cin>>n;
int T = 1;
vector<int> v = {1};
int ans[n + 1];
ans[1] = T++;
for(int i = 2;i <= n;i++){
if(!in(v, i)){
ans[i] = T++;
v.push_back(i);
continue;
}
int lo = 0, hi = v.size() - 1, res = v.size() - 1;
while(lo <= hi){
int mid = (lo + hi) / 2;
vector<int> u;
for(int i = 0;i <= mid;i++)u.push_back(v[i]);
if(in(u, i)){
res = mid;
hi = mid - 1;
}else lo = mid + 1;
}
ans[i] = ans[v[res]];
}
cout<<"0 ";
for(int i = 1;i <= n;i++)cout<<ans[i]<<" ";
cout<<endl;
}
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... |