Submission #709063

# Submission time Handle Problem Language Result Execution time Memory
709063 2023-03-13T05:35:25 Z vjudge1 Abracadabra (CEOI22_abracadabra) C++17
0 / 100
1109 ms 524288 KB
#pragma GCC optimize("O3", "unroll-loops") // "Ofast" 	
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 1e6 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const ld eps = 1e-6;

ll add (ll a, ll b) {
	a += b;
	if (a < 0) a += mod;
	if (a >= mod) a -= mod;
	return a;
}

ll mul (ll a, ll b) {
	a *= b;
	if (a >= mod) a %= mod;
	return a;
}

int n, q, a[N], b[N];

void mergesort () {
	vt<int> L, R, res;
	for (int i = 1; i <= n; i++) {
		if (i <= n / 2) L.pb(b[i]);
		else R.pb(b[i]);
	}
	int i = 0, j = 0;
	while (i < sz(L) && j < sz(R)) {
		if (L[i] < R[j]) res.pb(L[i]), i++;
		else res.pb(R[j]), j++;
	}
	while (i < sz(L)) res.pb(L[i]), i++;
	while (j < sz(R)) res.pb(R[j]), j++;
	for (i = 1; i <= n; i++) b[i] = res[i - 1];
}

vt<int> res[N];

void solve () {
	cin >> n >> q;
	for (int i = 1; i <= n; i++) cin >> a[i];
	vt<pii> v;
	int prv = -1, sub = 1, mx = 0;
	while (q--) {
		int t, i;
		cin >> t >> i;
		sub &= (prv == -1 || prv == t);
		prv = t;
		v.emplace_back(t, i - 1);
		mx = max(mx, t);
	}
	for (int i = 1; i <= n; i++) b[i] = a[i], res[0].pb(a[i]);
	for (int it = 1; it <= min(mx, 1000ll); it++) {
		mergesort();
		for (int j = 1; j <= n; j++) res[it].pb(b[j]);
	}
	for (auto [t, i]: v) cout << res[t][i] << '\n';
	cout << '\n';
}

bool testcases = 0;

signed main() {
/*#ifndef ONLINE_JUDGE
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif*/
	cin.tie(0) -> sync_with_stdio(0);
	int test = 1;
	if (testcases) cin >> test;
	for (int cs = 1; cs <= test; cs++) {
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 183 ms 96188 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 827 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1109 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 183 ms 96188 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -