Submission #1016572

# Submission time Handle Problem Language Result Execution time Memory
1016572 2024-07-08T08:21:48 Z amine_aroua Abracadabra (CEOI22_abracadabra) C++17
0 / 100
3000 ms 6144 KB
#include <bits/stdc++.h>
using namespace std;
int n;
void shuffle(vector<int> &v)
{
    deque<int> dq[2];
    for(int i = 0 ; i < n ; i++)
    {
        dq[i / (n/2)].push_back(v[i]);
    }
    vector<int> ret;
    while(!dq[0].empty() && !dq[1].empty())
    {
        ret.push_back(min(dq[0].front() , dq[1].front()));
        if(dq[0].front() < dq[1].front())
        {
            dq[0].pop_front();
        }
        else
        {
            dq[1].pop_front();
        }
    }
    for(int i = 0 ; i < 2 ; i++)
    {
        for(auto x : dq[i])
            ret.push_back(x);
    }
    v = ret;
}
int main() {
    int q;
    cin>>n>>q;
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++)
        cin>>a[i];
    while(q--)
    {
        int t , i;
        cin>>t>>i;
        i-- ;
        t = min(t , n - 1);
        vector<int> b = a;
        while(t--)
            shuffle(b);
        cout<<b[i]<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3045 ms 6144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3070 ms 3668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -