Submission #996080

#TimeUsernameProblemLanguageResultExecution timeMemory
996080IBoryAbracadabra (CEOI22_abracadabra)C++17
10 / 100
182 ms15484 KiB
#include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int MAX = 1004; int A[MAX][MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); int N, Q; cin >> N >> Q; for (int i = 1; i <= N; ++i) cin >> A[0][i]; for (int t = 1; t < MAX; ++t) { int a = 1, b = (N / 2) + 1, idx = 1; while (a <= N / 2 || b <= N) { if (N < b) A[t][idx++] = A[t - 1][a++]; else if (N / 2 < a) A[t][idx++] = A[t - 1][b++]; else A[t][idx++] = A[t - 1][(A[t - 1][a] < A[t - 1][b] ? a : b)++]; } } for (int i = 1; i <= Q; ++i) { int a, b; cin >> a >> b; a = min(a, MAX - 1); cout << A[a][b] << '\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...