# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
368402 | KoD | Sorting (IOI15_sorting) | C++17 | 725 ms | 15724 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 "sorting.h"
template <class T>
using Vec = std::vector<T>;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int ok = M, ng = -1;
while (ok - ng > 1) {
int md = (ok + ng) / 2;
Vec<int> perm(N);
Vec<int> inv(N);
std::iota(perm.begin(), perm.end(), 0);
std::iota(inv.begin(), inv.end(), 0);
const auto swap = [&](const int i, const int j) {
std::swap(perm[i], perm[j]);
inv[perm[i]] = i;
inv[perm[j]] = j;
};
for (int i = 0; i < md; ++i) {
swap(X[i], Y[i]);
}
std::queue<std::pair<int, int>> que;
{
Vec<int> to(N);
for (int i = 0; i < N; ++i) {
to[S[i]] = inv[i];
}
Vec<char> used(N);
for (int i = 0; i < N; ++i) {
# | 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... |