Submission #943394

#TimeUsernameProblemLanguageResultExecution timeMemory
943394Ahmed57Abracadabra (CEOI22_abracadabra)C++17
0 / 100
3031 ms4120 KiB
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "debug.cpp" #else #define debug(...) #endif signed main() { ios_base::sync_with_stdio(false);cin.tie(0); int n,q; cin>>n>>q; deque<int> v; vector<int> ver; ver.push_back({}); for(int i = 0;i<n;i++){ int x;cin>>x; ver.push_back(x); v.push_back(x); } int a,b;cin>>a>>b; while(a--){ deque<int> p1,p2,all; int x = n/2; while(x--){ p1.push_back(v[0]);v.pop_front(); } x = n/2; while(x--){ p2.push_back(v[0]);v.pop_front(); } while(p1.size()&&p2.size()){ if(p1[0]<p2[0]){ all.push_back(p1[0]);p1.pop_front(); }else{ all.push_back(p2[0]);p2.pop_front(); } } while(p1.size()){ all.push_back(p1[0]);p1.pop_front(); }while(p2.size()){ all.push_back(p2[0]);p2.pop_front(); } swap(v,all);bool ss = 0; for(int i = 0;i<n;i++){ if(ver[i]!=v[i]){ ss = 1; } } if(!ss)break; ver.clear(); for(int i = 0;i<n;i++){ ver.push_back(v[i]); } } q--; cout<<ver[b-1]<<endl; while(q--){ int a,b;cin>>a>>b; cout<<ver[b-1]<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...