Submission #867194

# Submission time Handle Problem Language Result Execution time Memory
867194 2023-10-27T20:28:35 Z PagodePaiva Abracadabra (CEOI22_abracadabra) C++17
10 / 100
2001 ms 524288 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n, q;
    cin >> n >> q;

    vector <int> v;
    for(int i = 1;i <= n;i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    vector <array <int, 3>> query;

    for(int i = 1;i <= q;i++){
        int a, b;
        cin >> a >> b;
        query.push_back({a, b, i});
    }

    sort(query.begin(), query.end());

    map <array <int, 3>, int> resp;
    map <vector <int>, int> mark;
    int st = 0;
    bool ac = true;

    for(auto x : query){
        while(st < x[0] and ac){
            mark[v] = 1;

            vector <int> a, b;

            for(int i = 0;i < n/2;i++){
                a.push_back(v[i]);
            }

            for(int i = n/2;i < n;i++){
                b.push_back(v[i]);
            }

            vector <int> next;
            int l = 0, r = 0;

            while(l < n/2 or r < n/2){
                if(r == n/2){
                    swap(a, b);
                    swap(l, r);
                }
                if(l == n/2){
                    for(int i = r;i < n/2;i++){
                        next.push_back(b[i]);
                    }
                    break;
                }

                if(a[l] < b[r]){
                    next.push_back(a[l]);
                    l++;
                }
                else{
                    next.push_back(b[r]);
                    r++;
                }
            }

            if(mark[next] == 1) ac = false;
            st++;
            v = next;
        }

        resp[x] = v[x[1]-1];
    }

    for(auto &x : query){
        swap(x[0], x[2]);
    }

    sort(query.begin(), query.end());

    for(auto x : query){
        cout << resp[{x[2], x[1], x[0]}] << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1769 ms 82696 KB Output is correct
2 Correct 1794 ms 79720 KB Output is correct
3 Correct 1439 ms 77528 KB Output is correct
4 Correct 1374 ms 76056 KB Output is correct
5 Correct 1454 ms 79020 KB Output is correct
6 Correct 1287 ms 75648 KB Output is correct
7 Correct 1419 ms 79304 KB Output is correct
8 Correct 1359 ms 75996 KB Output is correct
9 Correct 1372 ms 75988 KB Output is correct
10 Correct 1338 ms 76572 KB Output is correct
11 Correct 1408 ms 76240 KB Output is correct
12 Correct 1191 ms 76200 KB Output is correct
13 Correct 1370 ms 76832 KB Output is correct
14 Correct 1472 ms 78292 KB Output is correct
15 Correct 1433 ms 78260 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1158 ms 75852 KB Output is correct
18 Correct 1141 ms 75492 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1895 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2001 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1769 ms 82696 KB Output is correct
2 Correct 1794 ms 79720 KB Output is correct
3 Correct 1439 ms 77528 KB Output is correct
4 Correct 1374 ms 76056 KB Output is correct
5 Correct 1454 ms 79020 KB Output is correct
6 Correct 1287 ms 75648 KB Output is correct
7 Correct 1419 ms 79304 KB Output is correct
8 Correct 1359 ms 75996 KB Output is correct
9 Correct 1372 ms 75988 KB Output is correct
10 Correct 1338 ms 76572 KB Output is correct
11 Correct 1408 ms 76240 KB Output is correct
12 Correct 1191 ms 76200 KB Output is correct
13 Correct 1370 ms 76832 KB Output is correct
14 Correct 1472 ms 78292 KB Output is correct
15 Correct 1433 ms 78260 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1158 ms 75852 KB Output is correct
18 Correct 1141 ms 75492 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Runtime error 1895 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -