# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
444412 | blue | The Collection Game (BOI21_swaps) | C++17 | 70 ms | 496 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 "swaps.h"
#include <vector>
#include <iostream>
using namespace std;
int N;
int V;
vector<int> r;
void do_comparisons(vector<int> A, vector<int> B)
{
for(int i = 0; i < A.size(); i++)
{
schedule(r[ A[i] ], r[ B[i] ]);
}
vector<int> C = visit();
for(int i = 0; i < A.size(); i++)
{
if(C[i] == 0)
swap(r[ A[i] ], r[ B[i] ]);
}
}
void solve(int n, int v)
{
N = n;
V = v;
r = vector<int>(N);
for(int i = 1; i <= N; i++) r[i - 1] = i;
for(int v = 1; v <= min(V, N); v++)
{
vector<int> A, B;
if(v % 2 == 0)
{
for(int i = 0; i+1 < N; i += 2)
{
A.push_back(i);
B.push_back(i+1);
}
}
else
{
for(int i = 1; i+1 < N; i += 2)
{
A.push_back(i);
B.push_back(i+1);
}
}
do_comparisons(A, B);
}
answer(r);
}
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... |