# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
583345 | WongChun1234 | The Collection Game (BOI21_swaps) | C++14 | 65 ms | 428 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.
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include<bits/stdc++.h>
using namespace std;
const int N=550;
int rrl[N];
vector<pair<int,int>> sch;
void solve(int n, int v) {
// TODO implement this function
for (int i=1;i<=n;i++) rrl[i]=i;
for (int i=2;i<=n;i++){
for (int j=(i%2)+1;j<i;j+=2){
schedule(rrl[j],rrl[j+1]);
sch.push_back({rrl[j],rrl[j+1]});
}
vector<int> res=visit();
for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
if (res[j]){
//frnt < back, 60% must
//rrl[j] now has smaller one
}else{
//rrl[j] has bigger one
swap(rrl[pos],rrl[pos+1]);
}
}
sch.clear();
}
for (int i=n-1;i>=2;i--){
for (int j=(i%2)+1;j<i;j+=2){
schedule(rrl[j],rrl[j+1]);
sch.push_back({rrl[j],rrl[j+1]});
}
vector<int> res=visit();
for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
if (res[j]){
//frnt < back, 60% must
//rrl[j] now has smaller one
}else{
//rrl[j] has bigger one
swap(rrl[pos],rrl[pos+1]);
}
}
sch.clear();
}
vector<int> ans(n);
for (int i=1;i<=n;i++) ans[i-1]=rrl[i];
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... |