Submission #1196411

#TimeUsernameProblemLanguageResultExecution timeMemory
1196411anmattroiAbracadabra (CEOI22_abracadabra)C++17
10 / 100
392 ms8336 KiB
#include <bits/stdc++.h> #define maxn 200005 using namespace std; int n, q; int a[maxn], b[maxn], c[maxn]; void SHUFFLE() { int l = 1, r = n/2+1, id = 0; while (l <= n/2 || r <= n) { if (l == n/2+1) { for (int i = r; i <= n; i++) c[++id] = a[i]; break; } if (r == n+1) { for (int i = l; i <= n/2; i++) c[++id] = a[i]; break; } if (a[l] < a[r]) c[++id] = a[l++]; else c[++id] = a[r++]; } for (int i = 1; i <= n; i++) a[i] = c[i]; } int d[1005][1005]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i <= n; i++) { for (int j = 1; j <= n; j++) d[i][j] = a[j]; SHUFFLE(); } while (q--) { int t, i; cin >> t >> i; t = min(t, n); cout << d[t][i] << "\n"; } } /* 10 10 7 5 2 9 10 8 4 3 6 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...