Submission #936439

# Submission time Handle Problem Language Result Execution time Memory
936439 2024-03-01T19:28:19 Z JuanJL Abracadabra (CEOI22_abracadabra) C++17
0 / 100
577 ms 524288 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

#define fst first 
#define snd second
#define pb push_back
#define forn(i,a,b) for(int i = a; i < b; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n';
#define pi pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;

int main(){FIN;
	ll n,q; cin>>n>>q;
	vector<vector<ll>> states;
	states.pb({});
	states[0].resize(n);
	forn(i,0,n) cin>>states[0][i];
	
	bool repeat=false;
	while(!repeat){
		
		queue<ll> A,B;
		forn(i,0,n/2) A.push(states[SZ(states)-1][i]);
		forn(i,n/2,n) B.push(states[SZ(states)-1][i]);
		
		states.pb({});
		states[SZ(states)-1].resize(n);
		
		forn(i,0,n){
			if(A.empty()){
				states[SZ(states)-1][i]=B.front();	B.pop();
			}else if(B.empty()){
				states[SZ(states)-1][i]=A.front();	A.pop();
			}else if(A.front()<B.front()){
				states[SZ(states)-1][i]=A.front();	A.pop();
			}else{
				states[SZ(states)-1][i]=B.front();	B.pop();
			}
		}
		repeat = true;
		ll maxi = 0;
		forn(i,0,n/2) maxi = max(maxi,states[SZ(states)-1][i]);
		if(states[SZ(states)-1][n/2]<maxi) repeat = false;
	}
	
	ll t, i;
	while(q--){
		cin>>t>>i;
		if(SZ(states)<t){
			cout<<states[SZ(states)-1][i-1]<<'\n';
		}else{
			cout<<states[t][i-1]<<'\n';
		}
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 217 ms 19928 KB Output is correct
2 Correct 172 ms 13652 KB Output is correct
3 Correct 198 ms 15124 KB Output is correct
4 Correct 161 ms 10428 KB Output is correct
5 Correct 174 ms 12668 KB Output is correct
6 Correct 154 ms 11344 KB Output is correct
7 Correct 167 ms 13072 KB Output is correct
8 Correct 161 ms 11208 KB Output is correct
9 Correct 156 ms 10872 KB Output is correct
10 Correct 160 ms 11088 KB Output is correct
11 Correct 152 ms 10984 KB Output is correct
12 Correct 145 ms 9552 KB Output is correct
13 Correct 162 ms 10368 KB Output is correct
14 Correct 165 ms 11768 KB Output is correct
15 Correct 199 ms 10836 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 145 ms 9720 KB Output is correct
18 Correct 147 ms 9648 KB Output is correct
19 Runtime error 1 ms 348 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 577 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 537 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 217 ms 19928 KB Output is correct
2 Correct 172 ms 13652 KB Output is correct
3 Correct 198 ms 15124 KB Output is correct
4 Correct 161 ms 10428 KB Output is correct
5 Correct 174 ms 12668 KB Output is correct
6 Correct 154 ms 11344 KB Output is correct
7 Correct 167 ms 13072 KB Output is correct
8 Correct 161 ms 11208 KB Output is correct
9 Correct 156 ms 10872 KB Output is correct
10 Correct 160 ms 11088 KB Output is correct
11 Correct 152 ms 10984 KB Output is correct
12 Correct 145 ms 9552 KB Output is correct
13 Correct 162 ms 10368 KB Output is correct
14 Correct 165 ms 11768 KB Output is correct
15 Correct 199 ms 10836 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 145 ms 9720 KB Output is correct
18 Correct 147 ms 9648 KB Output is correct
19 Runtime error 1 ms 348 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -