#include "sorting.h"
#include <vector>
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
//bool already_sorted;
int temp;
//bool CHECKING=false, DEBUG=false;
// we are given S[], M, X[], Y[]
// we are to give P[], Q[]
vector<int> ns(N);
for(int i=0; i<N; i++){
ns[i] = S[i];
}
/*if(DEBUG)
{
for(auto x:ns){
cout<<x<<" ";
}cout<<"\n\n";
}*/
vector<int> trans(N);
for(int i=0; i<N; i++){
trans[ns[i]] = i;
}
for(int i=0; i<N; i++){
P[i] = i;
Q[i] = trans[i];
swap(ns[i], ns[trans[i]]);
// we have "swapped" positions `i` and `trans[i]`. whatever that means.
for(int i=0; i<N; i++){
trans[ns[i]] = i;
}
}
/*for(auto x:ns){
cout<<x<<" ";
}cout<<"\n\n";*/
return N;
}
# | 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... |