제출 #772672

#제출 시각아이디문제언어결과실행 시간메모리
772672dooweyAbracadabra (CEOI22_abracadabra)C++14
10 / 100
3071 ms31404 KiB
#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;
const int M = (int)1e6 + 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[M];

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;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'std::vector<int> shuffle(std::vector<int>)':
Main.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 0 ; i < P.size(); i ++ ){
      |                     ~~^~~~~~~~~~
Main.cpp:19:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         if(i < P.size() / 2) A.push(P[i]);
      |            ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...