# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039872 | Zicrus | Sorting (IOI15_sorting) | C++17 | 1 ms | 348 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"
using namespace std;
typedef long long ll;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
ll stkPtr = 0;
vector<ll> s(N);
for (int i = 0; i < N; i++) s[i] = S[i];
for (int i = 2; i < min(N, M); i++) {
swap(s[X[i]], s[Y[i]]);
ll id = find(s.begin(), s.end(), i) - s.begin();
if (i == id) { swap(s[X[i]], s[Y[i]]); continue; }
swap(s[i], s[id]);
P[stkPtr] = i;
Q[stkPtr] = id;
stkPtr++;
}
if (stkPtr < M) {
if (s[0] == 0) {
P[stkPtr] = 0;
Q[stkPtr] = 0;
stkPtr++;
}
else {
P[stkPtr] = 0;
Q[stkPtr] = 1;
stkPtr++;
}
}
return stkPtr;
}
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... |