Submission #831656

#TimeUsernameProblemLanguageResultExecution timeMemory
831656QwertyPiAbracadabra (CEOI22_abracadabra)C++14
10 / 100
3054 ms31760 KiB
#include <bits/stdc++.h> using namespace std; vector<int> shuffle(vector<int> a){ int n = a.size(); vector<int> a1(a.begin(), a.begin() + n / 2), a2(a.begin() + n / 2, a.end()); a1.push_back(1 << 30); a2.push_back(1 << 30); int l = 0, r = 0; vector<int> b; for(int i = 0; i < n; i++){ if(a1[l] < a2[r]) b.push_back(a1[l++]); else b.push_back(a2[r++]); } return b; } const int MAXN = 2e5 + 11; const int MAXQ = 1e6 + 11; int ans[MAXQ]; struct query{ int t, i, id; bool operator< (const query& o) const { return t < o.t; } }; int32_t main(){ int n, q; cin >> n >> q; vector<int> a1, a2; for(int i = 0; i < n; i++){ int v; cin >> v; a1.push_back(v); } vector<query> Q; for(int id = 0; id < q; id++){ int t, i; cin >> t >> i; Q.push_back({t, i, id}); } sort(Q.begin(), Q.end()); int ct = 0; bool fixed = false; for(auto q : Q){ while(ct < q.t && !fixed) { a2 = shuffle(a1); if(a1 == a2) fixed = true; a1 = a2; ct++; } ans[q.id] = a1[q.i - 1]; } for(int i = 0; i < q; i++){ cout << ans[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...