Submission #1116037

#TimeUsernameProblemLanguageResultExecution timeMemory
1116037Zero_OPAbracadabra (CEOI22_abracadabra)C++14
0 / 100
726 ms524288 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); #endif // LOCAL int N, Q; cin >> N >> Q; vector<int> p(N); for(int i = 0; i < N; ++i){ cin >> p[i]; --p[i]; } vector<vector<int>> results; results.emplace_back(p); auto shuffle_cards = [&](vector<int> p) -> vector<int>{ vector<int> q; int i = 0, j = N / 2; while(i < N / 2 || j < N){ if(i == N / 2) q.emplace_back(p[j++]); else if(j == N) q.emplace_back(p[i++]); else if(p[i] < p[j]) q.emplace_back(p[i++]); else q.emplace_back(p[j++]); } return q; }; for(int i = 1; i <= N; ++i){ results.emplace_back(shuffle_cards(p)); } while(Q--){ int t, i; cin >> t >> i; --i; t = min(t, N); cout << results[t][i] + 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...