# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705329 | cig32 | The Collection Game (BOI21_swaps) | C++17 | 17 ms | 436 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 "bits/stdc++.h"
using namespace std;
int p[501], pos[501];
void block(int B, int N) {
int count = 0;
vector<pair<int,int> > queries;
for(int k=1; k<=N; k+=(B<<1)) {
for(int l=k; l<k+B; l++) {
if((k<<1) + (B<<1) - 1 - l <= N) {
count++;
queries.push_back({p[l], p[k+k+(B<<1)-1-l]});
}
}
}
if(queries.empty())return;
for(pair<int,int> x: queries) schedule(x.first,x.second);
vector<int> res = visit();
for(int i=0; i<res.size(); i++) {
if(res[i] == 0) {
// Then A[i] > A[j]
swap(p[pos[queries[i].first]], p[pos[queries[i].second]]);
for(int j=1; j<=N; j++) pos[p[j]] = j;
}
}
}
void solve(int N, int V) {
// TODO implement this function
for(int i=1; i<=N; i++) p[i] = pos[i] = i;
int L = log2(N);
for(int i=1; i<=9; i++) {
int cc = 0;
for(int j=(1<<L); j>=1; j>>=1) {
cc++;
if(cc>i+1) break;
if(i==2 && j==(1<<L)/2) continue;
block(j, N);
}
}
vector<int> identity;
for(int i=1; i<=N; i++) identity.push_back(p[i]);
answer(identity);
}
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... |