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"
template <class T> using Vec = std::vector<T>;
void solve(int N, int V) {
Vec<int> ord(N);
std::iota(ord.begin(), ord.end(), 1);
int logn = 0;
while ((1 << logn) < N) logn += 1;
const int M = 1 << logn;
ord.resize(M, 0);
for (int h = 1; h <= logn; ++h) {
for (int t = h - 1; t >= 0; --t) {
for (int i = 0; i < M; ++i) {
const int j = i ^ (1 << t);
if (i < j) {
if (ord[i] == 0 or ord[j] == 0) {
if ((i >> h & 1) ^ (ord[i] == 0)) {
std::swap(ord[i], ord[j]);
}
} else {
schedule(ord[i], ord[j]);
}
}
}
const auto resp = visit();
int idx = 0;
for (int i = 0; i < M; ++i) {
const int j = i ^ (1 << t);
if (i < j and ord[i] != 0 and ord[j] != 0) {
if (!((i >> h & 1) ^ resp[idx++])) {
std::swap(ord[i], ord[j]);
}
}
}
}
}
ord.resize(N);
answer(ord);
}
# | 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... |