# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009897 | vako_p | Carnival (CEOI14_carnival) | C++14 | 7 ms | 600 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 ll long long
#define pb push_back
const int mxN = 1e6 + 5;
ll n,idx[mxN];
vector<ll> v,v1;
bool ok(ll mid){
v1.clear();
for(auto it : v) if(it >= mid) v1.pb(it);
cout << v1.size() << ' ';
for(auto it : v1) cout << it << ' ';
cout << endl;
ll x;
cin >> x;
return (x != v1.size());
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
v.pb(1);
ll k = 1;
idx[1] = 1;
for(int i = 2; i <= n; i++){
v.pb(i);
cout << v.size() << ' ';
for(auto it : v) cout << it << ' ';
cout << endl;
ll x;
cin >> x;
if(x == v.size()){
idx[i] = ++k;
}
else{
ll l = 0, r = i;
while(r > l + 1){
ll mid = l + (r - l) / 2;
if(ok(mid)) l = mid;
else r = mid;
}
idx[i] = idx[l];
v.pop_back();
}
}
cout << 0 << ' ';
for(int i = 1; i <= n; i++) cout << idx[i] << ' ';
cout.flush();
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... |