Submission #1198825

#TimeUsernameProblemLanguageResultExecution timeMemory
1198825ElayV13Abracadabra (CEOI22_abracadabra)C++20
0 / 100
985 ms82928 KiB
#include <bits/stdc++.h> using namespace std; vector < int > shuffle(vector < int > v) { int sz = v.size(); vector < int > f , s; for(int i = sz / 2 - 1;i >= 0;i--) { f.push_back(v[i]); } for(int i = v.size() - 1;i >= sz / 2;i--) { s.push_back(v[i]); } vector < int > res; while(res.size() < v.size()) { if(!f.size()) { res.push_back(s[s.size() - 1]); s.pop_back(); } else if(!s.size()) { res.push_back(f[f.size() - 1]); f.pop_back(); } else { if(f[f.size() - 1] > s[s.size() - 1]) { res.push_back(s[s.size() - 1]); s.pop_back(); } else { res.push_back(f[f.size() - 1]); f.pop_back(); } } } return res; } const int N = 1001; const int LOG = 20; int res[N][N * LOG]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int n , q; cin >> n >> q; vector < int > a(n); for(int &i : a) cin >> i; for(int i = 0;i <= n * LOG;i++) { if(i >= 1) a = shuffle(a); for(int j = 0;j < n;j++) res[i][j] = a[j]; } while(q--) { int t , idx; cin >> t >> idx; t %= (n * LOG); cout << res[t][idx - 1] << "\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...