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"
using namespace std;
void solve(int n, int v) {
vector<int> aa(n), ll(n), rr(n), lt;
int m, h, i, j, l, l_, tmp;
for (i = 0; i < n; i++)
aa[i] = i + 1;
for (l = 0; 1 << l < n; l++) {
m = 1 << l + 1;
for (i = 0; i < n; i++)
if (i % m * 2 < m && (j = i - i % m * 2 + m - 1) < n)
schedule(aa[i], aa[j]);
lt = visit();
for (i = 0, h = 0; i < n; i++)
if (i % m * 2 < m && (j = i - i % m * 2 + m - 1) < n && !lt[h++])
tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
for (l_ = l - 1; l_ >= 0; l_--) {
m = 1 << l_ + 1;
for (i = 0; i < n; i++)
if (i % m * 2 < m && (j = i + m / 2) < n)
schedule(aa[i], aa[j]);
lt = visit();
for (i = 0, h = 0; i < n; i++)
if (i % m * 2 < m && (j = i + m / 2) < n && !lt[h++])
tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
}
}
answer(aa);
}
Compilation message (stderr)
swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:12:14: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
12 | m = 1 << l + 1;
| ~~^~~
swaps.cpp:21:16: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
21 | m = 1 << l_ + 1;
| ~~~^~~
# | 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... |