답안 #784649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
784649 2023-07-16T11:30:55 Z boris_mihov Abracadabra (CEOI22_abracadabra) C++17
10 / 100
3000 ms 31508 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <cstring>
#include <vector>
#include <stack>

typedef long long llong;
const int MAXN = 200000 + 10;
const int MAXQ = 1000000 + 10;
const llong INF = 1e18;
const int INTINF = 1e9;

int n, q;
int a[MAXN];
int b[MAXN];
int output[MAXQ];
std::vector <std::pair <int,int>> v[MAXN];

void riffle()
{
    std::merge(a + 1, a + n/2 + 1, a + n/2 + 1, a + n + 1, b + 1);
    for (int i = 1 ; i <= n ; ++i)
    {
        a[i] = b[i];
    }
}

void solve()
{
    for (int i = 0 ; i <= n ; ++i)
    {
        for (const auto &[pos, idx] : v[i])
        {
            output[idx] = a[pos];
        }

        riffle();
    }
}

void print()
{
    for (int i = 1 ; i <= q ; ++i)
    {
        std::cout << output[i] << '\n';
    }
}

void input()
{
    std::cin >> n >> q;
    for (int i = 1 ; i <= n ; ++i)
    {
        std::cin >> a[i];
    }

    for (int i = 1 ; i <= q ; ++i)
    {
        int t, idx;
        std::cin >> t >> idx;
        v[std::min(t, n)].push_back({idx, i});
    }
}

void fastIOI()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIOI();
    input();
    solve();
    print();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 30744 KB Output is correct
2 Correct 162 ms 29268 KB Output is correct
3 Correct 154 ms 28680 KB Output is correct
4 Correct 160 ms 27348 KB Output is correct
5 Correct 158 ms 30752 KB Output is correct
6 Correct 180 ms 30460 KB Output is correct
7 Correct 164 ms 31508 KB Output is correct
8 Correct 168 ms 29136 KB Output is correct
9 Correct 146 ms 27988 KB Output is correct
10 Correct 167 ms 27896 KB Output is correct
11 Correct 151 ms 28220 KB Output is correct
12 Correct 153 ms 25544 KB Output is correct
13 Correct 149 ms 26992 KB Output is correct
14 Correct 159 ms 29744 KB Output is correct
15 Correct 177 ms 27552 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 174 ms 25908 KB Output is correct
18 Correct 149 ms 25676 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 2 ms 4980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3067 ms 28888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3071 ms 10008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 30744 KB Output is correct
2 Correct 162 ms 29268 KB Output is correct
3 Correct 154 ms 28680 KB Output is correct
4 Correct 160 ms 27348 KB Output is correct
5 Correct 158 ms 30752 KB Output is correct
6 Correct 180 ms 30460 KB Output is correct
7 Correct 164 ms 31508 KB Output is correct
8 Correct 168 ms 29136 KB Output is correct
9 Correct 146 ms 27988 KB Output is correct
10 Correct 167 ms 27896 KB Output is correct
11 Correct 151 ms 28220 KB Output is correct
12 Correct 153 ms 25544 KB Output is correct
13 Correct 149 ms 26992 KB Output is correct
14 Correct 159 ms 29744 KB Output is correct
15 Correct 177 ms 27552 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 174 ms 25908 KB Output is correct
18 Correct 149 ms 25676 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 2 ms 4980 KB Output is correct
21 Execution timed out 3067 ms 28888 KB Time limit exceeded
22 Halted 0 ms 0 KB -