# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
429885 | dolphingarlic | The Collection Game (BOI21_swaps) | C++14 | 9 ms | 408 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 <numeric>
#include <algorithm>
void solve(int N, int V) {
std::vector<int> ans(N);
std::iota(ans.begin(), ans.end(), 1);
int P2 = 1;
while (P2 < N) P2 <<= 1;
for (int P = 1; P < P2; P <<= 1)
for (int k = P; k; k >>= 1) {
std::vector<std::pair<int, int>> visited;
for (int j = k % P; j < P2 - k; j += 2 * k)
for (int i = 0; i < k && i + j + k < N; i++)
if ((i + j) / (2 * P) == (i + j + k) / (2 * P)) {
schedule(ans[i + j], ans[i + j + k]);
visited.push_back({i + j, i + j + k});
}
std::vector<int> visit_res = visit();
for (int i = 0; i < visit_res.size(); i++)
if (!visit_res[i])
std::swap(ans[visited[i].first], ans[visited[i].second]);
}
answer(ans);
}
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... |