# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117759 | zubec | Sorting (IOI15_sorting) | C++14 | 3 ms | 384 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 "sorting.h"
#include <bits/stdc++.h>
using namespace std;
int pos[200100];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int ans = 0;
for (int i = 0; i < N; i++){
pos[S[i]] = i;
}
for (int i = 0; i < N; i++){
if (S[i] != i){
int x = pos[i];
//cout << "kek " << i << ' ' << x << endl;
/*pos[S[x]] = x;
pos[i] = i;*/
swap(S[i], S[x]);
swap(pos[i], pos[S[x]]);
P[ans] = i;
Q[ans] = x;
++ans;
}
}
return ans;
}
/**
5
3 0 4 2 1
5
1 1
4 0
2 3
1 4
0 4
*/
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... |