Submission #1117156

#TimeUsernameProblemLanguageResultExecution timeMemory
1117156StefanSebezCarnival (CEOI14_carnival)C++14
100 / 100
16 ms764 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ld long double int Ask(vector<int>a){ cout<<a.size()<<" "; for(auto i:a) cout<<i<<" ";cout<<endl; int x;cin>>x;return x; } int main(){ int n;cin>>n; vector<int>b; for(int i=1;i<=n;i++){ b.pb(i);int x=Ask(b); if(x!=b.size()) b.pop_back(); } int res[n+10]={0}; for(int i=0;i<b.size();i++) res[b[i]]=i+1; for(int i=1;i<=n;i++){ int lb=lower_bound(b.begin(),b.end(),i)-b.begin(); if(lb<b.size()&&b[lb]==i) continue; int l=0,r=b.size()-1; while(l<=r){ int mid=l+r>>1; vector<int>temp; for(int j=0;j<=mid;j++) temp.pb(b[j]); temp.pb(i); int x=Ask(temp); if(x==temp.size()){l=mid+1;} else{res[i]=res[b[mid]],r=mid-1;} } } cout<<"0 "; for(int i=1;i<=n;i++) cout<<res[i]<<" ";cout<<endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int Ask(std::vector<int>)':
carnival.cpp:10:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   10 |  for(auto i:a) cout<<i<<" ";cout<<endl;
      |  ^~~
carnival.cpp:10:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   10 |  for(auto i:a) cout<<i<<" ";cout<<endl;
      |                             ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:18:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(x!=b.size()) b.pop_back();
      |      ~^~~~~~~~~~
carnival.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0;i<b.size();i++) res[b[i]]=i+1;
      |                 ~^~~~~~~~~
carnival.cpp:24:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if(lb<b.size()&&b[lb]==i) continue;
      |      ~~^~~~~~~~~
carnival.cpp:27:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |    int mid=l+r>>1;
      |            ~^~
carnival.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(x==temp.size()){l=mid+1;}
      |       ~^~~~~~~~~~~~~
carnival.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for(int i=1;i<=n;i++) cout<<res[i]<<" ";cout<<endl;
      |     ^~~
carnival.cpp:37:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |     for(int i=1;i<=n;i++) cout<<res[i]<<" ";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...