# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398685 | galca | The Collection Game (BOI21_swaps) | C++14 | 0 ms | 0 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 <vector>
using namespace std;
void solve(int 𝑁, int 𝑉 ) {
vector<int> res(N);
for (int i=0; i<N; i++) {
res[i] = i;
}
for (int k = 2; k <= N; k *= 2) {
for (int j = k/2; j > 0; j /= 2) {
for (i = 0; i < N; i++) {
int ip = i ^ j;
if (ip > i) {
if (i ^ k == 0) schedule(ip, i);
else schedule(i, ip);
}
}
vector<int> v = visit();
for (i = 0; i < N/2; i++) {
int ip = i ^ j;
if (ip > i) {
if (v[i]) {
int tmp = res[i];
res[i] = res[ip];
res[ip] = tmp;
}
}
}
}
}
answer(res);
}