Submission #919527

#TimeUsernameProblemLanguageResultExecution timeMemory
919527Alihan_8Carnival (CEOI14_carnival)C++17
100 / 100
5 ms944 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' #define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } int query(auto a){ cout << a.size() << ' '; for ( auto &x: a ){ cout << x + 1 << " "; } cout << ln; int c; cin >> c; return c; } void answer(auto &a){ cout << "0 "; for ( auto &x: a ){ cout << x << " "; } exit(0); } signed main(){ // ios_base::sync_with_stdio(false); // cin.tie(nullptr); int n; cin >> n; vector <vector<int>> a; auto f = [&](int l, int r, int q){ vector <int> t(1, q); for ( int i = l; i < r; i++ ){ t.pb(a[i].back()); } return query(t); }; for ( int i = 0; i < n; i++ ){ if ( f(0, (int)a.size(), i) == a.size() + 1 ){ a.pb({i}); continue; } int l = 0, r = (int)a.size() - 1; while ( l < r ){ int md = (l + r) >> 1; if ( f(l, md + 1, i) == md - l + 2 ){ l = md + 1; } else r = md; } a[l].pb(i); } vector <int> c(n); int it = 0; for ( auto &x: a ){ ++it; for ( auto &i: x ){ c[i] = it; } } answer(c); cout << '\n'; }

Compilation message (stderr)

carnival.cpp:31:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   31 | int query(auto a){
      |           ^~~~
carnival.cpp:40:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   40 | void answer(auto &a){
      |             ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:61:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         if ( f(0, (int)a.size(), i) == a.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...