Submission #867195

# Submission time Handle Problem Language Result Execution time Memory
867195 2023-10-27T20:32:00 Z PagodePaiva Abracadabra (CEOI22_abracadabra) C++14
10 / 100
3000 ms 78652 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;
    vector <int> ant;
    int st = 0;
    bool ac = true;

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

            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(next == ant) 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 1852 ms 78652 KB Output is correct
2 Correct 1840 ms 78644 KB Output is correct
3 Correct 1695 ms 76112 KB Output is correct
4 Correct 1739 ms 75204 KB Output is correct
5 Correct 1835 ms 78264 KB Output is correct
6 Correct 1747 ms 74904 KB Output is correct
7 Correct 1953 ms 78452 KB Output is correct
8 Correct 1729 ms 76108 KB Output is correct
9 Correct 1687 ms 76228 KB Output is correct
10 Correct 1757 ms 76972 KB Output is correct
11 Correct 1739 ms 76456 KB Output is correct
12 Correct 1407 ms 74928 KB Output is correct
13 Correct 1689 ms 76716 KB Output is correct
14 Correct 1769 ms 76972 KB Output is correct
15 Correct 1776 ms 78648 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1146 ms 76108 KB Output is correct
18 Correct 1247 ms 75704 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 27828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3036 ms 6016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1852 ms 78652 KB Output is correct
2 Correct 1840 ms 78644 KB Output is correct
3 Correct 1695 ms 76112 KB Output is correct
4 Correct 1739 ms 75204 KB Output is correct
5 Correct 1835 ms 78264 KB Output is correct
6 Correct 1747 ms 74904 KB Output is correct
7 Correct 1953 ms 78452 KB Output is correct
8 Correct 1729 ms 76108 KB Output is correct
9 Correct 1687 ms 76228 KB Output is correct
10 Correct 1757 ms 76972 KB Output is correct
11 Correct 1739 ms 76456 KB Output is correct
12 Correct 1407 ms 74928 KB Output is correct
13 Correct 1689 ms 76716 KB Output is correct
14 Correct 1769 ms 76972 KB Output is correct
15 Correct 1776 ms 78648 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1146 ms 76108 KB Output is correct
18 Correct 1247 ms 75704 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Execution timed out 3058 ms 27828 KB Time limit exceeded
22 Halted 0 ms 0 KB -