# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33429 | imaxblue | Carnival (CEOI14_carnival) | C++14 | 0 ms | 0 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 mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
int n;
vector<int> com[155];
int query(vector<int> V, vector<int> W){
cout << V.size()+W.size() << ' ';
fox(l, V.size()){
cout << V[l] << ' ';
}
fox(l, W.size()){
cout << W[l] << ' ';
}
cout << endl;
fflush(stdin);
int x;
cin >> x;
return x;
}
int query2(vector<int> V, int L, int R, int X){
cout << R-L+2 << ' ';
for(int l=L; l<=R; ++l){
cout << V[l] << ' ';
}
cout << X << ' ';
cout << endl;
fflush(stdin);
int x;
cin >> x;
return x;
}
vector<int> dfs(int L, int R){
if (L==R){
return vector<int>({R});
}
vector<int> v=dfs(L, (L+R)/2), w=dfs((L+R)/2+1, R), u=vector<int>();
if (query(v, w)!=v.size()+w.size()){
fox(l, w.size()){
if (query2(v, 0, v.size()-1, w[l])==v.size()+1){
u.pb(w[l]);
continue;
}
//continue;
int L=0, M, R=v.size()-1;
while(L!=R){
M=(L+R)/2;
if (query2(v, L, M, w[l])!=M-L+2) R=M;
else L=M+1;
}
fox(l2, com[w[l]].size()){
com[v[L]].pb(com[w[l]][l2]);
}
}
} else {
u=w;
}
fox(l, u.size()) v.pb(u[l]);
//cout << "*" << L << ' ' << R << endl;
//fox(l, v.size()) cout << v[l] << ' '; cout << endl;
return v;
}
int main(){
cin >> n;
fox1(l, n){
com[l]=vector<int>({l});
}
int ans[155]={0};
vector<int> v=dfs(1, n);
fox(l, v.size()){
fox(l2, com[v[l]].size()){
ans[com[v[l]][l2]]=l+1;
}
}
cout << "0 ;
fox1(l, n){
cout << ans[l] << ' ';
}
return 0;
}