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) {
if (V == 5000) {
Vec<char> done(N);
Vec<int> ans;
while (true) {
Vec<int> remain;
for (int i = 0; i < N; ++i) {
if (!done[i]) {
remain.push_back(i);
}
}
if (remain.empty()) {
break;
}
while (remain.size() > 1) {
Vec<int> next;
Vec<std::array<int, 2>> ask;
for (int i = 0; i + 1 < (int) remain.size(); i += 2) {
schedule(remain[i] + 1, remain[i + 1] + 1);
ask.push_back({remain[i + 1], remain[i]});
}
const auto ret = visit();
for (int i = 0; i < (int) ret.size(); ++i) {
next.push_back(ask[i][ret[i]]);
}
if (remain.size() % 2 == 1) {
next.push_back(remain.back());
}
remain = std::move(next);
}
done[remain[0]] = true;
ans.push_back(remain[0] + 1);
}
answer(ans);
} else {
}
}
# | 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... |