# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94891 | someone_aa | Sorting (IOI15_sorting) | C++17 | 0 ms | 0 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;
const int maxn = 110;
int value[maxn], index[maxn];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int br = 0;
for(int i=0;i<N;i++) {
value[i] = S[i];
index[S[i]] = i;
}
for(int i=0;i<N;i++) {
if(value[i] == i) continue;
P[br] = i;
Q[br] = index[i];
index[value[i]] = index[i];
value[index[i]] = value[i];
value[i] = i;
index[i] = i;
br++;
}
return br;
}