Submission #708637

# Submission time Handle Problem Language Result Execution time Memory
708637 2023-03-12T05:45:19 Z becaido Abracadabra (CEOI22_abracadabra) C++17
10 / 100
3000 ms 30620 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout (T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 2e5 + 5;
const int QSIZ = 1e6 + 5;

int n, q;
int ans[QSIZ];
vector<int> a;
tuple<int, int, int> ask[QSIZ];

vector<int> deal(vector<int> a) {
    vector<int> re;
    for (int i1 = 0, i2 = a.size() / 2; i1 < a.size() / 2 || i2 < a.size();) {
        if (i1 == a.size() / 2) re.pb(a[i2++]);
        else if (i2 == a.size()) re.pb(a[i1++]);
        else if (a[i1] < a[i2]) re.pb(a[i1++]);
        else re.pb(a[i2++]);
    }
    return re;
}

void solve() {
    cin >> n >> q;
    a.resize(n);
    for (int &x : a) cin >> x;
    FOR (i, 1, q) {
        auto &[t, p, id] = ask[i];
        cin >> t >> p;
        id = i;
    }
    sort(ask + 1, ask + q + 1);
    auto last = a;
    int cur = 0;
    bool f = 1;
    FOR (i, 1, q) {
        auto [t, p, id] = ask[i];
        while (f && cur < t) {
            cur++;
            a = deal(a);
            if (a == last) f = 0;
            last = a;
        }
        ans[id] = a[p - 1];
    }
    FOR (i, 1, q) cout << ans[i] << '\n';
}

int main() {
    Waimai;
    solve();
}

Compilation message

Main.cpp: In function 'std::vector<int> deal(std::vector<int>)':
Main.cpp:32:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i1 = 0, i2 = a.size() / 2; i1 < a.size() / 2 || i2 < a.size();) {
      |                                         ~~~^~~~~~~~~~~~~~
Main.cpp:32:65: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i1 = 0, i2 = a.size() / 2; i1 < a.size() / 2 || i2 < a.size();) {
      |                                                              ~~~^~~~~~~~~~
Main.cpp:33:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (i1 == a.size() / 2) re.pb(a[i2++]);
      |             ~~~^~~~~~~~~~~~~~~
Main.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         else if (i2 == a.size()) re.pb(a[i1++]);
      |                  ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 355 ms 27612 KB Output is correct
2 Correct 395 ms 27232 KB Output is correct
3 Correct 356 ms 26368 KB Output is correct
4 Correct 314 ms 25064 KB Output is correct
5 Correct 365 ms 26856 KB Output is correct
6 Correct 322 ms 25292 KB Output is correct
7 Correct 371 ms 27124 KB Output is correct
8 Correct 376 ms 25456 KB Output is correct
9 Correct 356 ms 25100 KB Output is correct
10 Correct 311 ms 25688 KB Output is correct
11 Correct 331 ms 25584 KB Output is correct
12 Correct 319 ms 24572 KB Output is correct
13 Correct 462 ms 25396 KB Output is correct
14 Correct 375 ms 26248 KB Output is correct
15 Correct 350 ms 26056 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 307 ms 24752 KB Output is correct
18 Correct 301 ms 24588 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3023 ms 30620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 5824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 355 ms 27612 KB Output is correct
2 Correct 395 ms 27232 KB Output is correct
3 Correct 356 ms 26368 KB Output is correct
4 Correct 314 ms 25064 KB Output is correct
5 Correct 365 ms 26856 KB Output is correct
6 Correct 322 ms 25292 KB Output is correct
7 Correct 371 ms 27124 KB Output is correct
8 Correct 376 ms 25456 KB Output is correct
9 Correct 356 ms 25100 KB Output is correct
10 Correct 311 ms 25688 KB Output is correct
11 Correct 331 ms 25584 KB Output is correct
12 Correct 319 ms 24572 KB Output is correct
13 Correct 462 ms 25396 KB Output is correct
14 Correct 375 ms 26248 KB Output is correct
15 Correct 350 ms 26056 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 307 ms 24752 KB Output is correct
18 Correct 301 ms 24588 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Execution timed out 3023 ms 30620 KB Time limit exceeded
22 Halted 0 ms 0 KB -