# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648403 | 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)
{
vector<vector<int>> ans(1);
for(int i=1; i<=N; i++)
{
ans[0].push_back(i);
}
int le=0, ri=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]);
}
}
vector<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.clear();
int l=0, r=br.size();
if(br[0].size()==1) l++, q[le]=br[0][0], le++;
if(br[br.size()-1].size()==1&&br.size()>1) r--, q[ri]=br[br.size()-1][0], ri--;
for(int i=l; i<r; i++)
{
ans.push_back(br[i]);
}
}
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... |