Submission #919527

# Submission time Handle Problem Language Result Execution time Memory
919527 2024-02-01T04:47:02 Z Alihan_8 Carnival (CEOI14_carnival) C++17
100 / 100
5 ms 944 KB
#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

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 time Memory Grader output
1 Correct 4 ms 436 KB Output is correct
2 Correct 3 ms 692 KB Output is correct
3 Correct 2 ms 692 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 436 KB Output is correct
6 Correct 1 ms 684 KB Output is correct
7 Correct 3 ms 944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 440 KB Output is correct
2 Correct 3 ms 684 KB Output is correct
3 Correct 3 ms 940 KB Output is correct
4 Correct 2 ms 696 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 3 ms 692 KB Output is correct
7 Correct 3 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 3 ms 692 KB Output is correct
4 Correct 2 ms 688 KB Output is correct
5 Correct 4 ms 688 KB Output is correct
6 Correct 3 ms 692 KB Output is correct
7 Correct 3 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 436 KB Output is correct
2 Correct 3 ms 436 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 5 ms 688 KB Output is correct
6 Correct 3 ms 688 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 3 ms 696 KB Output is correct
3 Correct 3 ms 696 KB Output is correct
4 Correct 3 ms 944 KB Output is correct
5 Correct 3 ms 692 KB Output is correct
6 Correct 3 ms 432 KB Output is correct
7 Correct 2 ms 692 KB Output is correct