# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
408983 | ly20 | The Collection Game (BOI21_swaps) | C++17 | 571 ms | 616 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 MAXN = 510;
vector <int> rs;
int inv[MAXN];
void solve(int N, int V) {
// TODO implement this function
int n = N, v = V;
for(int i = 1; i <= n; i++) {
rs.push_back(i);
inv[i] = i - 1;
}
for(int j = 0; j < V / 2; j++) {
vector <pair <int, int> > vs;
for(int i = 0; i < n; i += 2) {
if(i + 1 >= n) continue;
schedule(rs[i], rs[i + 1]);
vs.push_back(make_pair(rs[i], rs[i + 1]));
}
vector <int> qr = visit();
for(int i = 0; i < vs.size(); i++) {
if(qr[i] == 0) {
swap(rs[inv[vs[i].first]], rs[inv[vs[i].second]]);
swap(inv[vs[i].first], inv[vs[i].second]);
}
}
vs.clear();
for(int i = 1; i < n; i += 2) {
if(i + 1 >= n) continue;
schedule(rs[i], rs[i + 1]);
vs.push_back(make_pair(rs[i], rs[i + 1]));
}
qr = visit();
for(int i = 0; i < vs.size(); i++) {
if(qr[i] == 0) {
swap(rs[inv[vs[i].first]], rs[inv[vs[i].second]]);
swap(inv[vs[i].first], inv[vs[i].second]);
}
}
}
answer(rs);
}
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... |