# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
402944 | doowey | The Collection Game (BOI21_swaps) | C++14 | 7 ms | 472 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 long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
vector<int> ord;
void do_shit(vector<pii> shit){
for(auto x : shit){
schedule(ord[x.fi], ord[x.se]);
}
vector<int> gg = visit();
for(int i = 0 ; i < gg.size(); i ++ ){
if(!gg[i]){
swap(ord[shit[i].fi], ord[shit[i].se]);
}
}
}
void solve(int n, int q) {
int nx;
for(int i = 1; i <= n; i ++ ){
ord.push_back(i);
}
for(int k = 1; k < n * 2; k *= 2){
vector<pii> ash;
for(int i = 0 ; i < n; i ++ ){
nx = (i ^ (k - 1));
if(i < nx && nx < n)
ash.push_back(mp(i, nx));
}
do_shit(ash);
for(int v = k / 4; v > 0 ; v /= 2){
ash.clear();
for(int j = 0 ; j < n; j ++){
nx = (j ^ v);
if(j < nx && nx < n){
ash.push_back(mp(j, nx));
}
}
do_shit(ash);
}
}
answer(ord);
}
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... |