Submission #936459

# Submission time Handle Problem Language Result Execution time Memory
936459 2024-03-01T21:52:15 Z Edu175 Abracadabra (CEOI22_abracadabra) C++17
10 / 100
908 ms 524288 KB
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(ll i=a,ceoi=b;i<ceoi;i++)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define imp(v) for(auto kdjfhg:v)cout<<kdjfhg<<" ";cout<<"\n"
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

vector<ll> f(vector<ll>a){
	vector<ll>l,r;
	ll n=SZ(a);
	fore(i,0,n/2)l.pb(a[i]);
	fore(i,n/2,n)r.pb(a[i]);
	vector<ll>b;
	reverse(ALL(l)); reverse(ALL(r));
	while(SZ(l)+SZ(r)){
		if(!SZ(r)||(SZ(l)&&l.back()<r.back()))b.pb(l.back()),l.pop_back();
		else b.pb(r.back()),r.pop_back();
	}
	return b;
}

int main(){FIN;
	ll n,q; cin>>n>>q;
	vector<ll>a(n);
	fore(i,0,n)cin>>a[i],a[i]--;
	vector<vector<ll>>b={a};
	while(1){
		auto a_=f(a);
		if(a_==a)break;
		a=a_;
		b.pb(a);
	}
	while(q--){
		ll t,i; cin>>t>>i; i--;
		t=min(t,(ll)SZ(b)-1);
		cout<<b[t][i]+1<<"\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 255 ms 19732 KB Output is correct
2 Correct 160 ms 13680 KB Output is correct
3 Correct 197 ms 15184 KB Output is correct
4 Correct 142 ms 10320 KB Output is correct
5 Correct 160 ms 12656 KB Output is correct
6 Correct 152 ms 11488 KB Output is correct
7 Correct 159 ms 13116 KB Output is correct
8 Correct 156 ms 11036 KB Output is correct
9 Correct 145 ms 10832 KB Output is correct
10 Correct 159 ms 11348 KB Output is correct
11 Correct 147 ms 11032 KB Output is correct
12 Correct 137 ms 9552 KB Output is correct
13 Correct 144 ms 10324 KB Output is correct
14 Correct 153 ms 11900 KB Output is correct
15 Correct 157 ms 10668 KB Output is correct
16 Correct 1 ms 456 KB Output is correct
17 Correct 137 ms 9812 KB Output is correct
18 Correct 150 ms 9588 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 908 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 819 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 255 ms 19732 KB Output is correct
2 Correct 160 ms 13680 KB Output is correct
3 Correct 197 ms 15184 KB Output is correct
4 Correct 142 ms 10320 KB Output is correct
5 Correct 160 ms 12656 KB Output is correct
6 Correct 152 ms 11488 KB Output is correct
7 Correct 159 ms 13116 KB Output is correct
8 Correct 156 ms 11036 KB Output is correct
9 Correct 145 ms 10832 KB Output is correct
10 Correct 159 ms 11348 KB Output is correct
11 Correct 147 ms 11032 KB Output is correct
12 Correct 137 ms 9552 KB Output is correct
13 Correct 144 ms 10324 KB Output is correct
14 Correct 153 ms 11900 KB Output is correct
15 Correct 157 ms 10668 KB Output is correct
16 Correct 1 ms 456 KB Output is correct
17 Correct 137 ms 9812 KB Output is correct
18 Correct 150 ms 9588 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Runtime error 908 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -