Submission #837723

#TimeUsernameProblemLanguageResultExecution timeMemory
837723MohamedAhmed04Abracadabra (CEOI22_abracadabra)C++14
0 / 100
1782 ms524288 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...