Submission #1009897

#TimeUsernameProblemLanguageResultExecution timeMemory
1009897vako_pCarnival (CEOI14_carnival)C++14
100 / 100
7 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int mxN = 1e6 + 5; ll n,idx[mxN]; vector<ll> v,v1; bool ok(ll mid){ v1.clear(); for(auto it : v) if(it >= mid) v1.pb(it); cout << v1.size() << ' '; for(auto it : v1) cout << it << ' '; cout << endl; ll x; cin >> x; return (x != v1.size()); } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; v.pb(1); ll k = 1; idx[1] = 1; for(int i = 2; i <= n; i++){ v.pb(i); cout << v.size() << ' '; for(auto it : v) cout << it << ' '; cout << endl; ll x; cin >> x; if(x == v.size()){ idx[i] = ++k; } else{ ll l = 0, r = i; while(r > l + 1){ ll mid = l + (r - l) / 2; if(ok(mid)) l = mid; else r = mid; } idx[i] = idx[l]; v.pop_back(); } } cout << 0 << ' '; for(int i = 1; i <= n; i++) cout << idx[i] << ' '; cout.flush(); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'bool ok(long long int)':
carnival.cpp:18:12: 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]
   18 |  return (x != v1.size());
      |          ~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:36:8: 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]
   36 |   if(x == v.size()){
      |      ~~^~~~~~~~~~~
#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...