Submission #956688

# Submission time Handle Problem Language Result Execution time Memory
956688 2024-04-02T10:30:28 Z fskarica Abracadabra (CEOI22_abracadabra) C++14
10 / 100
2825 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fi first
#define se second
#define pii pair<int, int>

int n, q;
int x, y;
vector <int> v;
vector <int> sol[1000];

vector <int> f() {
    vector <int> ret;

    int a = 0;
    int b = n / 2;
    while (a < n / 2 || b < n) {
        if (a == n / 2) {
            ret.push_back(v[b]);
            b++;
        }
        else if (b == n) {
            ret.push_back(v[a]);
            a++;
        }
        else {
            if (v[a] < v[b]) {
                ret.push_back(v[a]);
                a++;
            }
            else {
                ret.push_back(v[b]);
                b++;
            }
        }
    }

    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    srand(time(0));

    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> x;

        v.push_back(x);
    }

//    for (int i = 1; i <= n; i++) v.push_back(i);
//    random_shuffle(v.begin(), v.end());

    int cnt = 0;
    sol[0] = v;

    while (true) {
        if (v == f()) break;

        v = f();

        cnt++;
        sol[cnt] = v;
    }

    while (q--) {
        cin >> x >> y;

        if (x > cnt) cout << sol[cnt][y - 1] << "\n";
        else cout << sol[x][y - 1] << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 166 ms 15956 KB Output is correct
2 Correct 159 ms 12592 KB Output is correct
3 Correct 146 ms 13284 KB Output is correct
4 Correct 145 ms 10264 KB Output is correct
5 Correct 155 ms 12116 KB Output is correct
6 Correct 143 ms 11096 KB Output is correct
7 Correct 150 ms 12196 KB Output is correct
8 Correct 144 ms 10892 KB Output is correct
9 Correct 139 ms 10632 KB Output is correct
10 Correct 148 ms 10732 KB Output is correct
11 Correct 139 ms 10836 KB Output is correct
12 Correct 141 ms 9552 KB Output is correct
13 Correct 143 ms 10324 KB Output is correct
14 Correct 146 ms 11348 KB Output is correct
15 Correct 143 ms 10572 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 139 ms 9788 KB Output is correct
18 Correct 138 ms 9824 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 844 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2825 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 166 ms 15956 KB Output is correct
2 Correct 159 ms 12592 KB Output is correct
3 Correct 146 ms 13284 KB Output is correct
4 Correct 145 ms 10264 KB Output is correct
5 Correct 155 ms 12116 KB Output is correct
6 Correct 143 ms 11096 KB Output is correct
7 Correct 150 ms 12196 KB Output is correct
8 Correct 144 ms 10892 KB Output is correct
9 Correct 139 ms 10632 KB Output is correct
10 Correct 148 ms 10732 KB Output is correct
11 Correct 139 ms 10836 KB Output is correct
12 Correct 141 ms 9552 KB Output is correct
13 Correct 143 ms 10324 KB Output is correct
14 Correct 146 ms 11348 KB Output is correct
15 Correct 143 ms 10572 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 139 ms 9788 KB Output is correct
18 Correct 138 ms 9824 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Runtime error 844 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -