# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857992 | lovrot | The Collection Game (BOI21_swaps) | C++17 | 0 ms | 344 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 <cstdio>
#include <algorithm>
#include <vector>
#define EB emplace_back
#define X first
#define Y second
#define MP make_pair
using namespace std;
typedef pair<int, int> pii;
void solve(int n, int v) {
int log = 0, m = 1;
vector<int> ANS;
for(; (1 << log) < n; ++log) { m <<= 1; }
for(int i = 0; i < m; ++i) ANS.EB(i < m - n ? -1 : i - m + n + 1);
for(int i = 1 << 1; i <= m; i <<= 1)
for(int j = i >> 1; j; j >>= 1) {
vector<pii> S;
for(int k = m - n; k < m; ++k) {
int l = k ^ j;
if(l > k) {
if(k & i) swap(l, k);
S.EB(MP(ANS[k], ANS[l]));
schedule(ANS[k], ANS[l]);
// if(k & i) S.EB(MP(ANS[l], ANS[k]));
// else S.EB(MP(ANS[k], ANS[l]));
}
}
vector<int> RES = visit();
for(int i = 0; i < RES.size(); ++i)
if(!RES[i])
swap(ANS[S[i].X], ANS[S[i].Y]);
S.clear();
}
for(int i = 0; i < n; ++i) ANS[i] = ANS[i + m - n];
ANS.erase(ANS.begin() + n, ANS.end());
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... |