Submission #27648

#TimeUsernameProblemLanguageResultExecution timeMemory
27648samir_droubiCarnival (CEOI14_carnival)C++14
100 / 100
29 ms2020 KiB
#include <bits/stdc++.h> using namespace std; const int mxn=155; int ty[mxn]; int n; int sz=0; int query(int l,int r) { int nm=0; for(int i=l;i<=r;++i) { if(ty[i]==0) ++nm; } printf("%d",nm); for(int i=l;i<=r;++i) { if(ty[i]==0) printf(" %d",i); } printf("\n"); fflush(stdout); int ans; scanf("%d",&ans); return ans; } int bs(int num) { int l=1; int r=n; int in=-1; while(l<=r) { int md=(l+r)/2; int x=query(1,md); if(x>num) r=md-1; else { l=md+1; in=md; } } return in; } int main() { scanf("%d",&n); sz=query(1,n)-1; int cur=1; while(sz) { while(true) { int in=bs(sz); if(in==n)break; ty[in+1]=cur; } ++cur; --sz; } for(int i=1;i<=n;++i) { if(ty[i]==0) ty[i]=cur; } printf("0"); for(int i=1;i<=n;++i) printf(" %d",ty[i]); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int query(int, int)':
carnival.cpp:24:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&ans);
                   ^
carnival.cpp: In function 'int main()':
carnival.cpp:48:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
#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...