Submission #942834

#TimeUsernameProblemLanguageResultExecution timeMemory
94283412345678Abracadabra (CEOI22_abracadabra)C++17
0 / 100
3030 ms10868 KiB
#include <bits/stdc++.h> using namespace std; const int nx=2e5+5; int n, q, idx[nx], res[nx], t; vector<int> v(nx), qrs[nx]; vector<int> shuffle(vector<int> x) { vector<int> l, r, res; res.push_back(0); for (int i=n/2; i>=1; i--) l.push_back(v[i]); for (int i=n; i>n/2; i--) r.push_back(v[i]); while (l.size()!=0||r.size()!=0) { if (r.empty()) res.push_back(l.back()), l.pop_back(); else if (l.empty()) res.push_back(r.back()), r.pop_back(); else if (l.back()<r.back()) res.push_back(l.back()), l.pop_back(); else res.push_back(r.back()), r.pop_back(); } return res; } int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>q; for (int i=1; i<=n; i++) cin>>v[i]; for (int i=1; i<=q; i++) cin>>t>>idx[i], qrs[min(n, t)].push_back(i); for (int i=0; i<=n; i++) { for (auto x:qrs[i]) res[x]=v[idx[x]]; v=shuffle(v); //for (int j=1; j<=n; j++) cout<<v[j]<<' '; //cout<<'\n'; } for (int i=1; i<=q; i++) cout<<res[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...