답안 #772667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
772667 2023-07-04T10:10:55 Z doowey Abracadabra (CEOI22_abracadabra) C++14
0 / 100
3000 ms 32412 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 10;

vector<int> shuffle(vector<int> P){
    queue<int> A, B;
    for(int i = 0 ; i < P.size(); i ++ ){
        if(i < P.size() / 2) A.push(P[i]);
        else B.push(P[i]);
    }
    vector<int> nex;
    while(!A.empty() || !B.empty()){
        if(A.empty()){
            nex.push_back(B.front());
            B.pop();
        }
        else if(B.empty()){
            nex.push_back(A.front());
            A.pop();
        }
        else {
            if(A.front() < B.front()){
                nex.push_back(A.front());
                A.pop();
            }
            else{
                nex.push_back(B.front());
                B.pop();
            }
        }
    }
    return nex;
}

vector<pii> qq[N]; // {index, idx}
int res[N];

int main(){
    fastIO;
    //freopen("test.txt", "r", stdin);
    int n, q;
    cin >> n >> q;
    vector<int> P(n);
    for(int i = 0 ; i < n; i ++ ){
        cin >> P[i];
    }
    int t, id;
    for(int iq = 1; iq <= q; iq ++ ){
        cin >> t >> id;
        t=min(t,n);
        qq[t].push_back(mp(id, iq));
    }
    for(int i = 0 ; i <= n; i ++ ){
        if(i) P = shuffle(P);
        for(auto x : qq[i]){
            res[x.se] = P[x.fi-1];
        }
    }
    for(int iq = 1; iq <= q; iq ++ ){
        cout << res[iq] << "\n";
    }
    return 0;
}

Compilation message

Main.cpp: In function 'std::vector<int> shuffle(std::vector<int>)':
Main.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0 ; i < P.size(); i ++ ){
      |                     ~~^~~~~~~~~~
Main.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(i < P.size() / 2) A.push(P[i]);
      |            ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 118 ms 32412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3069 ms 18116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3054 ms 10040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 118 ms 32412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -