#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]){
int now=0;
for(int i=N-1;i>=2;i--){
swap(S[X[now]],S[Y[now]]);
for(int j=i;j>=0;j--){
if(S[j]==i){
P[now]=i;
Q[now]=j;
swap(S[i],S[j]);
now++;
}
}
}
if(X[now]==Y[now]){
if(S[0]!=0){
P[now]=0;
Q[now]=1;
swap(S[0],S[1]);
now++;
}
}else if(X[now]==0 && Y[now]==1){
if(S[0]!=0){
swap(S[0],S[1]);
P[now]=Q[now]=0;
now++;
}
}
return now;
}
# | 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... |