# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
429093 | keko37 | The Collection Game (BOI21_swaps) | C++14 | 8 ms | 540 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<bits/stdc++.h>
#include "swaps.h"
using namespace std;
typedef pair <int, int> pi;
const int MAXN = 505;
int n, p[MAXN];
vector <pi> v;
void upd () {
for (auto pp : v) schedule(p[pp.first], p[pp.second]);
vector <int> ans = visit();
for (int i = 0; i < ans.size(); i++) {
if (ans[i] == 0) swap(p[v[i].first], p[v[i].second]);
}
}
void solve (int N, int V) {
n = N;
for (int i = 0; i < n; i++) p[i] = i + 1;
for (int i = 0; i < 9; i++) {
v.clear();
for (int pos = 0; pos < n; pos++) {
int par = pos ^ ((1 << (i + 1)) - 1);
if (par < pos) v.push_back({par, pos});
}
upd();
for (int j = i - 1; j >= 0; j--) {
v.clear();
for (int pos = 0; pos < n; pos++) {
int par = pos ^ (1 << j);
if (par < pos) v.push_back({par, pos});
}
upd();
}
}
vector <int> sol;
for (int i = 0; i < n; i++) sol.push_back(p[i]);
answer(sol);
}
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... |