답안 #968500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968500 2024-04-23T13:54:33 Z anton Abracadabra (CEOI22_abracadabra) C++17
0 / 100
1211 ms 524288 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
#define pii pair<int, int>


void shuffle(vector<int> &val){
    int k = val.size();
    vector<deque<int>> parts(2);
    for(int i =0; i<val.size()/2; i++){
        parts[0].push_back(val[i]);
        parts[1].push_back(val[i + val.size()/2]);
    }

    val.clear();
    while(val.size()<k){
        if(parts[0].size()==0){
            val.push_back(parts[1].front());
            parts[1].pop_front();
        }
        else if(parts[1].size()==0){
            val.push_back(parts[0].front());
            parts[0].pop_front();
        }
        else{
            if(parts[0].front()<parts[1].front()){
                val.push_back(parts[0].front());
                parts[0].pop_front();
            }
            else{
                val.push_back(parts[1].front());
                parts[1].pop_front();
            }
        }
    }
}

bool stable(vector<int>& r){
    int big = 0;
    for(int i = 0; i<r.size()/2; i++){
        big = max(big, r[i]);
    }
    return r[(r.size()/2 )+1] > big;

}
signed main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    
    int n, q;
    cin>>n>>q;
    vector<int> v(n);

    for(int i = 0; i<n; i++){
        cin>>v[i];
    }

    vector<vector<int>> results;
    results.push_back(v);


    for(int i = 1; !stable(results.back()); i++){
        results.push_back(results.back());
        shuffle(results.back());
    }


    for(int i = 0;i<q; i++){
        int t, j;
        cin>>t>>j;
        if(t>=results.size()){
            cout<<results.back()[j-1]<<endl;
        }
        else{
            cout<<results[t][j-1]<<endl;
        }
    }
}

Compilation message

Main.cpp: In function 'void shuffle(std::vector<long long int>&)':
Main.cpp:11:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i =0; i<val.size()/2; i++){
      |                   ~^~~~~~~~~~~~~
Main.cpp:17:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   17 |     while(val.size()<k){
      |           ~~~~~~~~~~^~
Main.cpp: In function 'bool stable(std::vector<long long int>&)':
Main.cpp:41:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0; i<r.size()/2; i++){
      |                    ~^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:72:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         if(t>=results.size()){
      |            ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1211 ms 15956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 701 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 685 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1211 ms 15956 KB Output isn't correct
2 Halted 0 ms 0 KB -