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 <iostream>
#include <vector>
#include <set>
using namespace std;
#define pb push_back
void solve(int N, int V) {
vector<int> Q, x, y;
for (int i = 1; i <= N; i++) {
Q.pb(i - 1);
}
for (int p = 1; p < N; p <<= 1) {
for (int k = p; k >= 1; k >>= 1) {
for (int j = k % p; j <= N - 1 - k; j += (k << 1)) {
for (int i = 0; i <= min(k - 1, N - j - k - 1); i++) {
if ((i + j) / (p << 1) == (i + j + k) / (p << 1)) {
int a = i + j, b = i + j + k;
x.pb(a);
y.pb(b);
schedule(Q[a] + 1, Q[b] + 1);
}
}
}
auto ret = visit();
for (int l = 0; l < (int)ret.size(); l++) {
if (!ret[l]) {
swap(Q[x[l]], Q[y[l]]);
}
}
x.clear();
y.clear();
}
}
for (int &i : Q) i++;
answer(Q);
}
# | 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... |