#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;
// we are given S[], M, X[], Y[]
// we are to give P[], Q[]
vector<int> ns;
for(int i=0; i<N; i++){
ns.push_back(S[i]);
}
for(int i=0; i<N; i++){
P[i] = i;
Q[i] = ns[i];
//swap(ns[i], ns[ns[i]]);
temp = ns[i];
ns[i] = ns[ns[i]];
ns[ns[i]] = temp;
already_sorted=true;
for(int j=1; j<N; j++){
if(ns[j-1] > ns[j]){
already_sorted=false;
break;
}
}
if(already_sorted){
return i+1;
}
}
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... |