This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,m;
vector<int> p;
vector<int> x,y;
vector<pair<int,int>> vec;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
if(N==1) return 0;
n=N;
m=M;
p.resize(n);
x.resize(m);
y.resize(m);
for(int i=0;i<n;i++){
p[i]=S[i];
}
for(int i=0;i<m;i++){
x[i]=X[i];
y[i]=Y[i];
}
int cnt=0;
for(int i=2;i<n;i++){
if(p[i]==0){
swap(p[0],p[1]);
swap(p[0],p[i]);
P[cnt]=0;
Q[cnt]=i;
cnt++;
break;
}
}
for(int i=2;i<n;i++){
if(p[i]==1){
swap(p[0],p[1]);
if(p[0]!=0) swap(p[0],p[i]),P[cnt]=0;
else swap(p[1],p[i]),P[cnt]=1;
Q[cnt]=i;
cnt++;
break;
}
}
for(int i=2;i<n;i++){
for(int j=i+1;j<n;j++){
if(S[j]==i){
swap(p[0],p[1]);
swap(S[i],S[j]);
P[cnt]=i;
Q[cnt]=j;
cnt++;
break;
}
}
}
return (p[0]==0?cnt:cnt+1);
}
# | 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... |