#include "sorting.h"
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ": " << x << '\n';
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
map<int, int> posi;
for(int i = 0; i < N; i++){
posi[S[i]] = i;
}
int swaps = 0;
for (int i = 0; i < N; i++){
if (S[i] != i) {
int j = posi[i];
P[swaps] = i;
Q[swaps] = j;
swaps++;
swap(S[i], S[j]);
posi[S[j]] = j;
posi[S[i]] = i;
}
}
return swaps;
}
# | 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... |