Submission #1085608

#TimeUsernameProblemLanguageResultExecution timeMemory
1085608vjudge1Carnival (CEOI14_carnival)C++17
100 / 100
5 ms484 KiB
#include <bits/stdc++.h> using namespace std; #define ld long double #define int long long #define ar array const int N = 1e6 + 20; int ask(vector<int> &v){ cout<<v.size()<<" "; for(auto u: v)cout<<u<<" "; cout<<endl; int x; cin>>x; return x; } bool in(vector<int> v,int x){ v.push_back(x); return ask(v) == (v.size() - 1); } signed main() {ios_base::sync_with_stdio(false);cin.tie(0); int n; cin>>n; int T = 1; vector<int> v = {1}; int ans[n + 1]; ans[1] = T++; for(int i = 2;i <= n;i++){ if(!in(v, i)){ ans[i] = T++; v.push_back(i); continue; } int lo = 0, hi = v.size() - 1, res = v.size() - 1; while(lo <= hi){ int mid = (lo + hi) / 2; vector<int> u; for(int i = 0;i <= mid;i++)u.push_back(v[i]); if(in(u, i)){ res = mid; hi = mid - 1; }else lo = mid + 1; } ans[i] = ans[v[res]]; } cout<<"0 "; for(int i = 1;i <= n;i++)cout<<ans[i]<<" "; cout<<endl; }

Compilation message (stderr)

carnival.cpp: In function 'bool in(std::vector<long long int>, long long int)':
carnival.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     return ask(v) == (v.size() - 1);
      |            ~~~~~~~^~~~~~~~~~~~~~~~~
#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...