Submission #837723

# Submission time Handle Problem Language Result Execution time Memory
837723 2023-08-25T14:44:50 Z MohamedAhmed04 Abracadabra (CEOI22_abracadabra) C++14
0 / 100
1782 ms 524288 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n , q ;

vector<int>v ;

vector<int>ans[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>q ;
	v.resize(n) ;
	for(auto &x : v)
		cin>>x ;
	ans[0] = v ;
	int last = 0 ;
	for(int k = 1 ; ; ++k)
	{
		vector<int>v2[2] ;
		for(int i = n-1 ; i >= 0 ; --i)
			v2[(i >= n/2)].push_back(ans[k-1][i]) ;
		for(int i = 0 ; i < n ; ++i)
		{
			bool t = 0 ;
			if((!v2[0].size()) || (v2[1].size() && v2[0].back() > v2[1].back()))
				t = 1 ;
			ans[k].push_back(v2[t].back()) ;
			v2[t].pop_back() ;
		}
		last = k ;
		if(ans[k] == ans[k-1])
			break ;
	}
	assert(last <= 100) ;
	while(q--)
	{
		int t , idx ;
		cin>>t>>idx ;
		t = min(t , last) ;
		cout<<ans[t][idx-1]<<"\n" ;
	}
	return 0 ;
}		
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 13468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1782 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1768 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 13468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -