# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43404 | Hassoony | Carnival (CEOI14_carnival) | C++14 | 8 ms | 2412 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;
typedef long long ll;
const int MX=1e5+9;
int n,p[MX];
int find(int x){
if(x==p[x])return x;
return p[x]=find(p[x]);
}
map<int,int>hashy;
void merge_(int x,int y){
x=find(x);
y=find(y);
p[y]=x;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)p[i]=i;
for(int i=1;i<=n;i++){
vector<int>v;
for(int j=1;j<i;j++){
if(j==find(j))v.push_back(j);
}
cout<<v.size()+1<<" "<<i<<" ";
for(auto pp:v)cout<<pp<<" ";
cout<<endl;
int x;
scanf("%d",&x);
if(x==v.size()+1)continue;
int l=0,r=v.size()-1,ans=0;
while(l<=r){
int mid=(l+r)/2;
cout<<mid-l+2<<" "<<i<<" ";
for(int j=l;j<=mid;j++)cout<<v[j]<<" ";
cout<<endl;
scanf("%d",&x);
if(x==mid-l+2){
ans=mid+1;
l=mid+1;
}
else r=mid-1;
}
merge_(v[ans],i);
}
for(int i=1;i<=n;i++){
hashy[p[i]]=1;
}
int tt=0;
for(auto pp:hashy){
hashy[pp.first]=++tt;
}
cout<<0<<" ";
for(int i=1;i<n;i++)cout<<hashy[p[i]]<<" ";
cout<<hashy[p[n]]<<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... |