Submission #668601

# Submission time Handle Problem Language Result Execution time Memory
668601 2022-12-04T08:42:02 Z aebov Abracadabra (CEOI22_abracadabra) C++17
10 / 100
1316 ms 8816 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define ln (e-s+1)
#define lc (id<<1)
#define rc ((id<<1)+1)
#define md ((e+s)>>1)
#define dm (((e+s)>>1)+1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll , ll>
#define F first
#define S second
//#define cin fin
using namespace std;

const int N = 1002;
int n, q, t, x, tmp, lst = 0;
vector<int> state[N];

void doj(int lev){
	if(lev > n) return;
	int p1 = 0, p2 = (n-1) / 2 + 1, p3 = ((n-1)>>1) + 1;
	while(p1 < p3 || p2 < n){
		if(p1 < p3 && p2 < n){
			if(state[lev-1][p1] < state[lev-1][p2]) state[lev].pb(state[lev-1][p1]), p1 ++;
			else state[lev].pb(state[lev-1][p2]), p2 ++;
		}
		else if(p1 < p3){
			state[lev].pb(state[lev-1][p1]), p1 ++;
		}
		else state[lev].pb(state[lev-1][p2]), p2 ++;
	}
	if(state[lev] != state[lev-1])doj(lev + 1), lst ++;
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> q;
	if( n > 1000)exit(0);
	for(int i = 0; i < n; i ++) cin >> tmp, state[0].pb(tmp);
	doj(1);
/*	for(int i = 0; i < 4 ; i ++){
		cout << endl;
		for(auto x : state[i])cout << x << " ";
	}*/
	while(q --){
		cin >> t >> x;
		t = min(t, lst);
		cout << state[t][x-1] << endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1316 ms 8816 KB Output is correct
2 Correct 1294 ms 6612 KB Output is correct
3 Correct 1240 ms 7292 KB Output is correct
4 Correct 1195 ms 5516 KB Output is correct
5 Correct 1293 ms 6184 KB Output is correct
6 Correct 1203 ms 5680 KB Output is correct
7 Correct 1270 ms 6424 KB Output is correct
8 Correct 1260 ms 5720 KB Output is correct
9 Correct 1204 ms 5520 KB Output is correct
10 Correct 1238 ms 5532 KB Output is correct
11 Correct 1204 ms 5532 KB Output is correct
12 Correct 1194 ms 5264 KB Output is correct
13 Correct 1243 ms 5368 KB Output is correct
14 Correct 1288 ms 5992 KB Output is correct
15 Correct 1305 ms 5496 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1291 ms 5288 KB Output is correct
18 Correct 1217 ms 5404 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1316 ms 8816 KB Output is correct
2 Correct 1294 ms 6612 KB Output is correct
3 Correct 1240 ms 7292 KB Output is correct
4 Correct 1195 ms 5516 KB Output is correct
5 Correct 1293 ms 6184 KB Output is correct
6 Correct 1203 ms 5680 KB Output is correct
7 Correct 1270 ms 6424 KB Output is correct
8 Correct 1260 ms 5720 KB Output is correct
9 Correct 1204 ms 5520 KB Output is correct
10 Correct 1238 ms 5532 KB Output is correct
11 Correct 1204 ms 5532 KB Output is correct
12 Correct 1194 ms 5264 KB Output is correct
13 Correct 1243 ms 5368 KB Output is correct
14 Correct 1288 ms 5992 KB Output is correct
15 Correct 1305 ms 5496 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1291 ms 5288 KB Output is correct
18 Correct 1217 ms 5404 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Incorrect 0 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -