Submission #789124

#TimeUsernameProblemLanguageResultExecution timeMemory
789124ymmAbracadabra (CEOI22_abracadabra)C++17
10 / 100
600 ms524288 KiB
#include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) typedef long long ll; using namespace std; vector<int> shf(vector<int> vec) { int n = vec.size(); vector<int> ans; int p0 = 0, p1 = n/2; Loop (_,0,n) { if (p1 == n || (p0 < n/2 && vec[p0] < vec[p1])) ans.push_back(vec[p0++]); else ans.push_back(vec[p1++]); } return ans; } vector<vector<int>> vecs; int main() { cin.tie(0) -> sync_with_stdio(false); int n, q; cin >> n >> q; vector<int> vec(n); for (int &x : vec) cin >> x; vecs.push_back(vec); for (;;) { vec = shf(vec); if (vecs.back() == vec) break; vecs.push_back(vec); } while (q--) { int t, i; cin >> t >> i; --i; t = min<int>(t, vecs.size()-1); cout << vecs[t][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...