Submission #688109

# Submission time Handle Problem Language Result Execution time Memory
688109 2023-01-27T07:08:59 Z ksjsjsjsjsjsjs Abracadabra (CEOI22_abracadabra) C++14
0 / 100
65 ms 8004 KB
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define bg begin
#define ed end
#define ft front
#define bk back
#define ins insert
#define ers erase
#define sz(x) (int)(x).size()
#define all(x) (x).bg(), (x).ed()
#define mtp make_tuple
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define str string
#define pi pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)
#define FOS(i, r, l) for (int i = (r); i >= (l); --i)
#define FRN(i, n) for (int i = 0; i < (n); ++i)
#define FSN(i, n) for (int i = (n) - 1; i >= 0; --i)
#define EACH(i, x) for (auto &i : (x))
#define WHILE while
template<typename T> T gcd(T a, T b) { WHILE(b) { a %= b; swap(a, b); } return b; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
const int oo = 1e9 + 5;
const int N = 2e5 + 5;
int n, q, a[N];
pi b[N];
namespace subtask1 {
    const int N = 2005;
    int a1[N][N], num = 0;
    void solve() {
        FOR(i, 1, n) a1[0][i] = a[i];
        FOR(t, 1, oo) {
            int l = 1, r = n / 2 + 1;
            FOR(j, 1, n)
                if (l <= n / 2 && r <= n) {
                    if (a1[t - 1][l] < a1[t - 1][r]) a1[t][j] = a1[t - 1][l++];
                    else a1[t][j] = a1[t - 1][r++];
                }
                else if (l <= n / 2) a1[t][j] = a1[t - 1][l++];
                else a1[t][j] = a1[t - 1][r++];
            bool ok = 1;
            FOR(j, 1, n)
                if (a1[t][j] != a1[t - 1][j])
                    ok = 0;
            if (ok) {
                num = t;
                break;
            }
        }
        FOR(i, 1, q) {
            b[i].st = min(b[i].st, num);
            cout << a1[b[i].st][b[i].nd] << '\n';
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen(file".inp", "r", stdin);
//    freopen(file".out", "w", stdout);
    cin >> n >> q;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, q) cin >> b[i].st >> b[i].nd;
    if (n <= 1000) {
        subtask1::solve();
        return 0;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 5384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 8004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 3148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 5384 KB Output isn't correct
2 Halted 0 ms 0 KB -