답안 #709070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709070 2023-03-13T05:54:21 Z vjudge1 Abracadabra (CEOI22_abracadabra) C++17
0 / 100
3000 ms 21816 KB
//Bismillahir-Rahmanir-Rahim

#include <bits/stdc++.h>
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")*/

#define Respa return
#define gold 0

#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long>
#define ll long long
#define ld long double
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define sz(s) (int)s.size()
#define skip continue
#define bpop(x) (ll)__builtin_popcountll(x)

using namespace std;

const int N = 3e5 + 7;
const int K = 5e2 + 7;
const int MAXA = 5e4 + 7;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;
const ll MOD = (1ll << 30);

pii dir[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

#define int long long

int n, q, a[N], b[N];
void f() {
    vector <int> av, bv;
    for (int i = 1;i <= n / 2;i++)av.pb(a[i]);
    for (int i = n / 2 + 1;i <= n;i++)bv.pb(a[i]);
    av.pb(INF), bv.pb(INF);
    int l = 0, r = 0, pos = 0;
    while (l < n / 2 || r < n / 2) {
        if (av[l] <= bv[r])b[++pos] = av[l++];
        else b[++pos] = bv[r++];
    }
    for (int i = 1;i <= n;i++)a[i] = b[i];
}
void solve() {
    cin >> n >> q;
    vector <pii> qs;
    for (int i = 1;i <= n;i++)cin >> a[i];
    for (int i = 1;i <= q;i++) {
        int t, p;
        cin >> t >> p;
        qs.pb({t, p});
    }
    sort(all(qs));
    int last = 0;
    for (int i = 0;i < q;i++) {
        int t = qs[i].x, pos = qs[i].y;
        if (t - last == 0)cout << a[pos] << '\n';
        else {
            if (t > n)cout << a[pos] << '\n';
            else {
                int x = t - last;
                while (x--)f();
                cout << a[pos] << '\n';
            }
        }
        last = t;
    }
}
signed main() {
    //srand(time(NULL));
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("G.in", "r", stdin);
    //freopen("G.out", "w", stdout);
    int test = 1;
    //cin >> test;
    for (int i = 1;i <= test;i++) {
        //cout << "Case " << i << ": ";
        solve();
    }
    Respa gold;//2022-2023 InshAllah
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 290 ms 19992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3061 ms 21816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3040 ms 5436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 290 ms 19992 KB Output isn't correct
2 Halted 0 ms 0 KB -