# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053681 | XJP12 | Sorting (IOI15_sorting) | C++14 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#include "sorting.h"
using namespace std;
typedef vector<int> vi;
int findSwapPairs(int n, vi s, int m, vi x, vi y, vi p, vi q) {
int r=0;
if(y[0]==1){
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(s[j]==i && j!=i){
p[i]=j;
q[i]=i;
swap(s[i], s[j]);
r++;
break;
}
}
swap(s[1], s[0]);
}
if(s[1]!=1 && s[0]!=0){
p[r]=0;
q[r]=1;
r++;
}
}else{
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(s[j]==i && j!=i){
p[i]=j;
q[i]=i;
swap(s[i], s[j]);
r++;
break;
}
}
}
}
return r;
}