| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1352987 | raineyj | Abracadabra (CEOI22_abracadabra) | C++20 | 3095 ms | 20080 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<vector<int>> s(2, vector<int>(n));
for(int i=0; i<n; i++) cin >> s[0][i];
priority_queue<pair<int, pair<int, int>>> queries;
vector<int> ans(q);
for(int i=0; i<q; i++)
{
int t, p;
cin >> t >> p;
queries.push({-t,{p-1, i}});
}
int shuf=0;
while(!queries.empty())
{
int t=-queries.top().first, p=queries.top().second.first, i=queries.top().second.second;
queries.pop();
while(shuf<t && s[0]!=s[1])
{
shuf+=1;
int l=0, r=n/2;
for(int j=0; j<n; j++)
{
if(l>=n/2)
{
s[shuf%2][j]=s[(shuf+1)%2][r];
r++;
}
else if(r>=n)
{
s[shuf%2][j]=s[(shuf+1)%2][l];
l++;
}
else if(s[(shuf+1)%2][l]<s[(shuf+1)%2][r])
{
s[shuf%2][j]=s[(shuf+1)%2][l];
l++;
}
else
{
s[shuf%2][j]=s[(shuf+1)%2][r];
r++;
}
}
}
ans[i]=s[t%2][p];
}
for(auto a : ans) cout << a << '\n';
}| # | 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... | ||||
