Submission #985892

#TimeUsernameProblemLanguageResultExecution timeMemory
985892simona1230Carnival (CEOI14_carnival)C++17
100 / 100
4 ms716 KiB
#include <bits/stdc++.h> using namespace std; int n,num; int in[256]; int a[256]; int guess(vector<int> v) { cout<<v.size()<<" "; for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl; cout.flush(); int val; cin>>val; return val; } void solve() { for(int i=1;i<=n;i++) { in[i]=1; vector<int> v; for(int j=1;j<=i;j++) if(in[j])v.push_back(j); int x=guess(v); if(x>num) { num++; a[i]=num; continue; } in[i]=0; vector<int> h; int ans=0; int l=0,r=v.size()-2; while(l<=r) { if(l==r) { ans=v[l]; break; } int m=(l+r)/2; h.clear(); for(int j=l;j<=m;j++) h.push_back(v[j]); h.push_back(i); x=guess(h); if(x==m-l+1) { r=m; } else { l=m+1; } } a[i]=a[ans]; } cout<<"0 "; for(int i=1;i<=n;i++) cout<<a[i]<<" "; cout<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; solve(); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int guess(std::vector<int>)':
carnival.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
#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...