#include<bits/stdc++.h>
#include "sorting.h"
#define MAXN 200007
using namespace std;
int n,m,q;
int pos[MAXN],s[MAXN];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
n=N; m=M;
if(n==1)return 0;
for(int i=0;i<n;i++)s[i]=S[i];
for(int i=0;i<n;i++){
if(X[0]==0 and Y[0]==1)swap(s[0],s[1]);
for(int f=0;f<n;f++){
if(s[f]==i){
P[i]=i; Q[i]=f;
swap(s[i],s[f]);
}
}
}
q++;
P[q-1]=Q[q-1]=0;
for(int i=0;i<n;i++)s[i]=S[i];
for(int i=0;i<q;i++){
for(int t=0;t<n-1;t++){
if(s[t]>s[t+1])break;
else if(t==n-2)return i;
}
if(X[0]==0 and Y[0]==1)swap(s[0],s[1]);
swap(s[P[i]],s[Q[i]]);
}
return q;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |