# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648402 | berr | The Collection Game (BOI21_swaps) | C++17 | 1 ms | 208 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>
#include "swaps.h"
using namespace std;
void solve(int N, int V)
{
deque<vector<int>> ans(1);
for(int i=1; i<=N; i++)
{
ans[0].push_back(i);
}
int l=0, r=N-1;
vector<int> q(N);
while(ans.size())
{
for(int i=0; i<ans.size(); i++)
{
for(int l=0; l<ans[i].size()-1; l+=2)
{
schedule(ans[i][l], ans[i][l+1]);
}
}
deque<vector<int>> br(ans.size()+1);
auto b=visit();
int f=0;
for(int i=0; i<ans.size(); i++)
{
for(int l=0; l<ans[i].size()-1; l+=2)
{
if(b[f]==1) br[i].push_back(ans[i][l]), br[i+1].push_back(ans[i][l+1]);
else br[i].push_back(ans[i][l+1]), br[i+1].push_back(ans[i][l]);
f++;
}
if(ans[i].size()%2) br[i].push_back(ans[i][ans[i].size()-1]);
}
ans=br;
int k=0;
while(ans.size()&&ans[0].size()==1)
{
q[l]=ans[0][0];
ans.pop_front();
l++;
}
while(ans.size()&&ans[ans.size()-1].size()==1)
{
q[r]=ans[ans.size()-1][0];
ans.pop_back();
r--;
}
}
answer(q);
}
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... |
# | 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... |
# | 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... |