Submission #791390

#TimeUsernameProblemLanguageResultExecution timeMemory
791390t6twotwoAbracadabra (CEOI22_abracadabra)C++17
0 / 100
790 ms524288 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; void shuffle(vector<int> &a) { int n = a.size(); vector<int> b; int j = n / 2; for (int i = 0; i < n / 2; i++) { while (j < n && a[j] < a[i]) { b.push_back(a[j++]); } b.push_back(a[i]); } for (int i = j; i < n; i++) { b.push_back(a[i]); } swap(a, b); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> A(N); for (int &x : A) { cin >> x; } vector<vector<int>> T; set<vector<int>> S; do { T.push_back(A); S.insert(A); shuffle(A); } while (!S.count(A)); int M = T.size(); while (Q--) { int t, i; cin >> t >> i; i--; cout << T[t % M][i] << "\n"; } return 6/22; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...