#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 time |
Memory |
Grader output |
1 |
Incorrect |
159 ms |
15920 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
703 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
726 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
159 ms |
15920 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |