Submission #1016576

#TimeUsernameProblemLanguageResultExecution timeMemory
1016576amine_arouaAbracadabra (CEOI22_abracadabra)C++17
10 / 100
1413 ms524288 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<vector<int>> all; vector<int> shuffle(vector<int> v) { deque<int> dq[2]; for(int i = 0 ; i < n ; i++) { dq[i / (n/2)].push_back(v[i]); } vector<int> ret; while(!dq[0].empty() && !dq[1].empty()) { ret.push_back(min(dq[0].front() , dq[1].front())); if(dq[0].front() < dq[1].front()) { dq[0].pop_front(); } else { dq[1].pop_front(); } } for(int i = 0 ; i < 2 ; i++) { for(auto x : dq[i]) ret.push_back(x); } return ret; } int main() { int q; cin>>n>>q; all.assign(n , {}); vector<int> a(n); for(int i = 0 ; i < n ; i++) cin>>a[i]; all[0] = a; for(int i =1 ; i <= n - 1; i++) all[i] = shuffle(all[i - 1]); while(q--) { int t , i; cin>>t>>i; i-- ; t = min(t , n - 1); cout<<all[t][i]<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...