Submission #43404

#TimeUsernameProblemLanguageResultExecution timeMemory
43404HassoonyCarnival (CEOI14_carnival)C++14
100 / 100
8 ms2412 KiB
#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)

carnival.cpp: In function 'int main()':
carnival.cpp:30:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(x==v.size()+1)continue;
             ^
carnival.cpp:18:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
carnival.cpp:29:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
carnival.cpp:37:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&x);
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...