답안 #867192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867192 2023-10-27T20:26:03 Z PagodePaiva Abracadabra (CEOI22_abracadabra) C++14
10 / 100
1585 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;i++){
                        next.push_back(b[i]);
                    }
                }

                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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1418 ms 101644 KB Output is correct
2 Correct 1441 ms 96064 KB Output is correct
3 Correct 1357 ms 86336 KB Output is correct
4 Correct 1316 ms 79272 KB Output is correct
5 Correct 1461 ms 83968 KB Output is correct
6 Correct 1377 ms 80360 KB Output is correct
7 Correct 1445 ms 84884 KB Output is correct
8 Correct 1427 ms 143572 KB Output is correct
9 Correct 1375 ms 79608 KB Output is correct
10 Correct 1386 ms 81188 KB Output is correct
11 Correct 1432 ms 154520 KB Output is correct
12 Correct 1180 ms 79536 KB Output is correct
13 Correct 1387 ms 143284 KB Output is correct
14 Correct 1410 ms 155216 KB Output is correct
15 Correct 1394 ms 82792 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1125 ms 85480 KB Output is correct
18 Correct 1084 ms 86596 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1585 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 852 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1418 ms 101644 KB Output is correct
2 Correct 1441 ms 96064 KB Output is correct
3 Correct 1357 ms 86336 KB Output is correct
4 Correct 1316 ms 79272 KB Output is correct
5 Correct 1461 ms 83968 KB Output is correct
6 Correct 1377 ms 80360 KB Output is correct
7 Correct 1445 ms 84884 KB Output is correct
8 Correct 1427 ms 143572 KB Output is correct
9 Correct 1375 ms 79608 KB Output is correct
10 Correct 1386 ms 81188 KB Output is correct
11 Correct 1432 ms 154520 KB Output is correct
12 Correct 1180 ms 79536 KB Output is correct
13 Correct 1387 ms 143284 KB Output is correct
14 Correct 1410 ms 155216 KB Output is correct
15 Correct 1394 ms 82792 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1125 ms 85480 KB Output is correct
18 Correct 1084 ms 86596 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Runtime error 1585 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -