답안 #1016576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1016576 2024-07-08T08:24:53 Z amine_aroua Abracadabra (CEOI22_abracadabra) C++17
10 / 100
1413 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> all;
vector<int> 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);
    }
    return ret;
}
int main() {
    int q;
    cin>>n>>q;
    all.assign(n , {});
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++)
        cin>>a[i];
    all[0] = a;
    for(int i =1 ; i <= n - 1; i++)
        all[i] = shuffle(all[i - 1]);
    while(q--)
    {
        int t , i;
        cin>>t>>i;
        i-- ;
        t = min(t , n - 1);
        cout<<all[t][i]<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1404 ms 15956 KB Output is correct
2 Correct 1371 ms 15524 KB Output is correct
3 Correct 1326 ms 15188 KB Output is correct
4 Correct 1319 ms 14044 KB Output is correct
5 Correct 1362 ms 15444 KB Output is correct
6 Correct 1303 ms 14364 KB Output is correct
7 Correct 1289 ms 15500 KB Output is correct
8 Correct 1313 ms 14300 KB Output is correct
9 Correct 1293 ms 14380 KB Output is correct
10 Correct 1409 ms 14236 KB Output is correct
11 Correct 1285 ms 14452 KB Output is correct
12 Correct 1406 ms 13340 KB Output is correct
13 Correct 1341 ms 14084 KB Output is correct
14 Correct 1276 ms 14932 KB Output is correct
15 Correct 1413 ms 14548 KB Output is correct
16 Correct 9 ms 4440 KB Output is correct
17 Correct 1338 ms 13648 KB Output is correct
18 Correct 1286 ms 13652 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1059 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1079 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1404 ms 15956 KB Output is correct
2 Correct 1371 ms 15524 KB Output is correct
3 Correct 1326 ms 15188 KB Output is correct
4 Correct 1319 ms 14044 KB Output is correct
5 Correct 1362 ms 15444 KB Output is correct
6 Correct 1303 ms 14364 KB Output is correct
7 Correct 1289 ms 15500 KB Output is correct
8 Correct 1313 ms 14300 KB Output is correct
9 Correct 1293 ms 14380 KB Output is correct
10 Correct 1409 ms 14236 KB Output is correct
11 Correct 1285 ms 14452 KB Output is correct
12 Correct 1406 ms 13340 KB Output is correct
13 Correct 1341 ms 14084 KB Output is correct
14 Correct 1276 ms 14932 KB Output is correct
15 Correct 1413 ms 14548 KB Output is correct
16 Correct 9 ms 4440 KB Output is correct
17 Correct 1338 ms 13648 KB Output is correct
18 Correct 1286 ms 13652 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Runtime error 1059 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -