답안 #677105

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677105 2023-01-02T09:48:48 Z stanislavpolyn Abracadabra (CEOI22_abracadabra) C++17
0 / 100
3000 ms 29504 KB
#include <bits/stdc++.h>

#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define fe(x, y) for (auto& x : y)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define all(x) (x).begin(), (x).end()
#define pw(x) (1LL << (x))
#define sz(x) (int)(x).size()

using namespace std;

mt19937_64 rng(228);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key

template <typename T>
bool umn(T& a, T b) {
    return a > b ? (a = b, 1) : 0;
}
template <typename T>
bool umx(T& a, T b) {
    return a < b ? (a = b, 1) : 0;
}

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;

const int N = 2e5 + 5;

int n, q;
int a[N];
int ans[N];
ve<array<int, 3>> Q;
int b[N];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif

    cin >> n >> q;

    fr (i, 1, n) {
        cin >> a[i];
    }

    fr (i, 1, q) {
        int t, pos;
        cin >> t >> pos;
        Q.pb({t, pos, i});
    }
    sort(all(Q));

    bool ok = 0;
    int curT = 0;
    fr (i, 0, sz(Q) - 1) {
        while (!ok && curT < Q[i][0]) {
            int ptr1 = 1;
            int ptr2 = n / 2 + 1;
            int ptr = 1;

            while (ptr1 <= n / 2 || ptr2 <= n) {
                if (ptr1 <= n / 2 && ptr2 <= n) {
                    if (a[ptr1] < a[ptr2]) {
                        b[ptr++] = a[ptr1++];
                    } else {
                        b[ptr++] = a[ptr2++];
                    }
                } else {
                    if (ptr1 <= n / 2) {
                        b[ptr++] = a[ptr1++];
                    } else {
                        b[ptr++] = a[ptr2++];
                    }
                }
            }
            bool same = 1;
            fr (i, 1, n) {
                same &= a[i] == b[i];
                a[i] = b[i];
            }

            if (same) {
                ok = 1;
            }

            curT++;
        }

        ans[Q[i][2]] = a[Q[i][1]];
    }

    fr (i, 1, q) {
        cout << ans[i] << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 277 ms 29504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3023 ms 27672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3065 ms 4468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 277 ms 29504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -