Submission #918199

# Submission time Handle Problem Language Result Execution time Memory
918199 2024-01-29T13:28:38 Z vjudge1 Carnival (CEOI14_carnival) C++17
100 / 100
6 ms 1276 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
using namespace std;

#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
    ios_base::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)\

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
map<vi, int> mp;

int ask(vi &v){
    if(mp[v])   return mp[v];
    cout << v.size() << " ";
    for(int i : v){
        cout << i << " ";
    }
    cout << endl;
    int x;
    cin >> x;
    return mp[v] = x;
}

signed main(){
    int n;
    cin >> n;
    int a[n + 5], pre = 0;
    vi v;
    for(int i = 1; i <= n; i++){
        v.push_back(i);
        int k = ask(v);
        if(k > pre){
            a[i] = k;
            pre = k;
        }
        else{
            v.pop_back();
            int l = 0, r = v.size() - 1, ans = -1;
            while(l < r){
                int mid = (l + r) / 2;
                vi tmp;
                for(int i = 0; i <= mid; i++){
                    tmp.push_back(v[i]);
                }
                int pre = ask(tmp);
                tmp.push_back(i);
                int nw = ask(tmp);
                if(nw == pre){
                    r = mid;
                }
                else{
                    l = mid + 1;
                }
            }
            a[i] = a[v[l]];
        }
    }
    cout << 0 << " ";
    for(int i = 1; i <= n; i++){
        cout << a[i] << " ";
    }
    cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:51:42: warning: unused variable 'ans' [-Wunused-variable]
   51 |             int l = 0, r = v.size() - 1, ans = -1;
      |                                          ^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1112 KB Output is correct
2 Correct 5 ms 756 KB Output is correct
3 Correct 4 ms 444 KB Output is correct
4 Correct 2 ms 704 KB Output is correct
5 Correct 2 ms 704 KB Output is correct
6 Correct 1 ms 440 KB Output is correct
7 Correct 3 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 952 KB Output is correct
2 Correct 5 ms 1208 KB Output is correct
3 Correct 3 ms 692 KB Output is correct
4 Correct 2 ms 696 KB Output is correct
5 Correct 3 ms 696 KB Output is correct
6 Correct 3 ms 696 KB Output is correct
7 Correct 3 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 5 ms 952 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 3 ms 952 KB Output is correct
6 Correct 3 ms 696 KB Output is correct
7 Correct 6 ms 1000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 692 KB Output is correct
2 Correct 3 ms 948 KB Output is correct
3 Correct 3 ms 1212 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 4 ms 1276 KB Output is correct
6 Correct 3 ms 956 KB Output is correct
7 Correct 4 ms 1208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 696 KB Output is correct
2 Correct 4 ms 712 KB Output is correct
3 Correct 4 ms 968 KB Output is correct
4 Correct 4 ms 984 KB Output is correct
5 Correct 4 ms 956 KB Output is correct
6 Correct 3 ms 948 KB Output is correct
7 Correct 2 ms 1204 KB Output is correct