# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648353 | berr | The Collection Game (BOI21_swaps) | C++17 | 135 ms | 11580 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<array<int, 2>> a[V];
vector<vector<int>> vis(V, vector<int>(N+1));
vector<int> ans(N+1), pos(N+1);
for(int i=1; i<=N; i++) ans[i]=i, pos[i]=i;
for(int i=1; i<=N; i++)
{
for(int l=i+1; l<=N; l++)
{
int flag=1;
for(int j=0; j<V&&flag; j++)
{
if(vis[j][i]==0&&vis[j][l]==0)
{
a[j].push_back({i, l});
vis[j][i]=1;
vis[j][l]=1;
flag=0;
}
}
}
}
for(int i=0; i<V; i++)
{
for(auto l: a[i]) schedule(l[0], l[1]);
auto b=visit();
for(int l=0; l<a[i].size(); l++)
{
if(b[l]==0&&pos[a[i][l][0]]>pos[a[i][l][1]]) swap(ans[pos[a[i][l][0]]], ans[pos[a[i][l][1]]]), swap(pos[a[i][l][0]], pos[a[i][l][1]]);
if(b[l]==1&&pos[a[i][l][0]]<pos[a[i][l][1]])swap(ans[pos[a[i][l][0]]], ans[pos[a[i][l][1]]]), swap(pos[a[i][l][0]], pos[a[i][l][1]]);
}
}
vector<int> s;
for(int i=N; i>=1; i--) s.push_back(ans[i]);
answer(s);
}
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... |