Submission #317983

#TimeUsernameProblemLanguageResultExecution timeMemory
317983nandonathanielCarnival (CEOI14_carnival)C++14
100 / 100
37 ms384 KiB
#include<bits/stdc++.h> using namespace std; int ans[155],x; int tanya(int l,int r){ cout << r-l+1; for(int i=l;i<=r;i++){ cout << " " << i; } cout << endl; cin >> x; return x; } bool valid(int l,int r){ int y=tanya(l,r); set<int> S; for(int i=l;i<r;i++)S.insert(ans[i]); return S.size()==y; } int main(){ int n,x; cin >> n; ans[1]=1; int last=1,no=1; for(int i=2;i<=n;i++){ int x=tanya(1,i); if(x>last){ no++; ans[i]=no; last=x; continue; } int ki=1,ka=i-1,res; while(ki<=ka){ int mid=(ki+ka)/2; if(valid(mid,i)){ res=mid; ki=mid+1; } else ka=mid-1; } ans[i]=ans[res]; } cout << 0; for(int i=1;i<=n;i++)cout << " " << ans[i]; cout << endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'bool valid(int, int)':
carnival.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  return S.size()==y;
      |         ~~~~~~~~^~~
carnival.cpp: In function 'int main()':
carnival.cpp:24:8: warning: unused variable 'x' [-Wunused-variable]
   24 |  int n,x;
      |        ^
carnival.cpp:45:17: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |   ans[i]=ans[res];
      |          ~~~~~~~^
#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...