Submission #666096

#TimeUsernameProblemLanguageResultExecution timeMemory
666096bin9638Carnival (CEOI14_carnival)C++17
100 / 100
23 ms356 KiB
#include<bits/stdc++.h> using namespace std; #define N 2112 #define ll long long #define ii pair<int,int> #define fs first #define sc second #define pb push_back int kq[N],check[N],n,judge=2,ktr[N],dp[N]; struct DSU { int lab[N]; void init() { memset(lab,-1,sizeof(lab)); } int root(int u) { if(lab[u]<0) return u; return(lab[u]=root(lab[u])); } void update(int u,int v) { if((u=root(u))==(v=root(v))) return; if(lab[u]>lab[v]) swap(u,v); lab[u]+=lab[v]; lab[v]=u; } }T; struct jury { int a[N]={},cnt[N]; void init() { cout<<"cc\n"; for(int i=1;i<=n;i++) cin>>a[i]; } int get() { int res=0; memset(cnt,0,sizeof(cnt)); for(int i=1;i<=n;i++) if(ktr[i]==1) { if(++cnt[a[i]]==1) res++; } return res; } }jury; void solve(int vt) { int l=vt+1,r=n,pos=-1; while(l<=r) { int mid=(l+r)/2; memset(ktr,0,sizeof(ktr)); for(int i=1;i<=n;i++) ktr[i]=(T.root(i)!=T.root(vt)&&i<=mid); int val,dem=0; for(int i=1;i<=n;i++) if(ktr[i]) dem++; cout<<dem<<" "; for(int i=1;i<=n;i++) if(ktr[i]) cout<<i<<" "; cout<<endl; if(judge==1) val=jury.get(); else cin>>val; if(val==dp[mid]) { pos=mid; r=mid-1; }else l=mid+1; } if(pos!=-1) T.update(pos,vt); // cout<<vt<<" "<<pos<<endl; } int main() { //// freopen("A.inp","r",stdin); //// freopen("A.out","w",stdout); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n; if(judge==1) jury.init(); T.init(); for(int i=1;i<=n;i++) { ktr[i]=1; cout<<i<<" "; for(int j=1;j<=i;j++)cout<<j<<" ";cout<<endl; if(judge==1) dp[i]=jury.get(); else cin>>dp[i]; } for(int i=1;i<n;i++) solve(i); int dem=0; for(int i=1;i<=n;i++) if(check[i]==0) { dem++; for(int j=1;j<=n;j++) if(T.root(j)==T.root(i)) { kq[j]=dem; check[j]=1; } } cout<<0<<" "; for(int i=1;i<=n;i++) cout<<kq[i]<<" "; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:113:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  113 |         for(int j=1;j<=i;j++)cout<<j<<" ";cout<<endl;
      |         ^~~
carnival.cpp:113:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  113 |         for(int j=1;j<=i;j++)cout<<j<<" ";cout<<endl;
      |                                           ^~~~
#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...