# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
847524 | SUNWOOOOOOOO | Abracadabra (CEOI22_abracadabra) | C++17 | 768 ms | 524288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector <vector <int>> deck;
int n, q;
vector <int> next_deck(vector <int> cur)
{
int i = 0, j = 0;
vector <int> A;
while (i < n / 2 || j < n / 2){
if (i != n / 2 && (j == n / 2 || cur[i] < cur[j + n / 2])) {A.push_back(cur[i]); i++;}
else {A.push_back(cur[j + n / 2]); j++;}
}
return A;
}
int main()
{
vector <int> v;
scanf("%d %d", &n, &q);
for (int i = 0, a; i < n; i++) {
scanf("%d", &a);
v.push_back(a);
}
deck.push_back(v);
for (int i = 0; i < n; i++){
vector <int> v = next_deck(deck.back());
if (v == deck.back()) break;
deck.push_back(v);
}
vector <int> ans;
while (q--){
int t, i;
scanf("%d %d", &t, &i);
t = min(t, (int) deck.size() - 1);
ans.push_back(deck[t][i - 1]);
}
for (int elm : ans) printf("%d\n", elm);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |