답안 #1116054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116054 2024-11-21T08:21:20 Z Zero_OP Abracadabra (CEOI22_abracadabra) C++14
10 / 100
703 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

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

#ifdef LOCAL
    freopen("task.inp", "r", stdin);
    freopen("task.out", "w", stdout);
#endif // LOCAL

    int N, Q;
    cin >> N >> Q;

    vector<int> p(N);
    for(int i = 0; i < N; ++i){
        cin >> p[i];
        --p[i];
    }

    vector<vector<int>> results;
    results.emplace_back(p);

    auto shuffle_cards = [&](vector<int> p) -> vector<int>{
        vector<int> q;
        int i = 0, j = N / 2;
        while((i < N / 2) || (j < N)){
            if(i == N / 2) q.emplace_back(p[j++]);
            else if(j == N) q.emplace_back(p[i++]);
            else if(p[i] < p[j]) q.emplace_back(p[i++]);
            else q.emplace_back(p[j++]);
        }
        assert((int)q.size() == N);
        return q;
    };

    for(int i = 1; i <= N; ++i){
        results.emplace_back(shuffle_cards(results.back()));
    }


    while(Q--){
        int t, i;
        cin >> t >> i;
        --i;

        t = min(t, N);
        cout << results[t][i] + 1 << '\n';
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 172 ms 8264 KB Output is correct
2 Correct 155 ms 15688 KB Output is correct
3 Correct 160 ms 15176 KB Output is correct
4 Correct 146 ms 14152 KB Output is correct
5 Correct 155 ms 15432 KB Output is correct
6 Correct 161 ms 14408 KB Output is correct
7 Correct 148 ms 15416 KB Output is correct
8 Correct 134 ms 14408 KB Output is correct
9 Correct 137 ms 14408 KB Output is correct
10 Correct 141 ms 14408 KB Output is correct
11 Correct 144 ms 14664 KB Output is correct
12 Correct 137 ms 13640 KB Output is correct
13 Correct 131 ms 14152 KB Output is correct
14 Correct 137 ms 14832 KB Output is correct
15 Correct 134 ms 14668 KB Output is correct
16 Correct 5 ms 4432 KB Output is correct
17 Correct 123 ms 13640 KB Output is correct
18 Correct 128 ms 13712 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 703 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 667 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 172 ms 8264 KB Output is correct
2 Correct 155 ms 15688 KB Output is correct
3 Correct 160 ms 15176 KB Output is correct
4 Correct 146 ms 14152 KB Output is correct
5 Correct 155 ms 15432 KB Output is correct
6 Correct 161 ms 14408 KB Output is correct
7 Correct 148 ms 15416 KB Output is correct
8 Correct 134 ms 14408 KB Output is correct
9 Correct 137 ms 14408 KB Output is correct
10 Correct 141 ms 14408 KB Output is correct
11 Correct 144 ms 14664 KB Output is correct
12 Correct 137 ms 13640 KB Output is correct
13 Correct 131 ms 14152 KB Output is correct
14 Correct 137 ms 14832 KB Output is correct
15 Correct 134 ms 14668 KB Output is correct
16 Correct 5 ms 4432 KB Output is correct
17 Correct 123 ms 13640 KB Output is correct
18 Correct 128 ms 13712 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Runtime error 703 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -