This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define vb vector<bool>
#define vi vector<int>
#define vpii vector<pii>
#define vvb vector<vb>
#define vvi vector<vi>
#define vvpii vector<vpii>
#define sz(x) (int)(x).size()
int N, V;
void solve(int _N, int _V)
{
N = _N, V = _V;
vvi ans(N);
vi todo;
for (int i = 1; i <= N; ++i)
todo.push_back(i);
ans[0].push_back(todo.back()), todo.pop_back();
if (N > 1)
ans[0].push_back(todo.back()), todo.pop_back();
while (sz(ans.back()) == 0)
{
for (int i = 0; i < N; ++i)
if (sz(ans[i]) > 1)
schedule(ans[i][0], ans[i][1]);
vi v = visit();
for (int i = N - 1; i >= 0; --i)
if (sz(ans[i]) > 1)
{
if (!v.back())
swap(ans[i][0], ans[i][1]);
v.pop_back();
}
for (int i = N - 2; i >= 0; --i)
if (sz(ans[i]) > 1)
ans[i + 1].push_back(ans[i].back()), ans[i].pop_back();
if (sz(todo) > 0)
ans[0].push_back(todo.back()), todo.pop_back();
}
vi formalAns;
for (int i = 0; i < N; ++i)
formalAns.push_back(ans[i][0]);
answer(formalAns);
}
# | 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... |