# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1195171 | nikulid | Sorting (IOI15_sorting) | C++20 | 0 ms | 0 KiB |
#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;
//bool CHECKING=false, DEBUG=false;
// we are given S[], M, X[], Y[]
// we are to give P[], Q[]
vector<int> ns(N);
for(int i=0; i<N; i++){
ns[i] = S[i];
}
/*if(DEBUG)
{
for(auto x:ns){
cout<<x<<" ";
}cout<<"\n\n";
}*/
for(int i=0; i<N; i++){
for(int j=0; j<N; j++){
if(ns[j] == i){
next = j;
break;
}
}
P[i] = i;
Q[i] = next;
swap(ns[i], ns[next]);
// we have "swapped" positions `i` and `trans[i]`. whatever that means.
}
/*for(auto x:ns){
cout<<x<<" ";
}cout<<"\n\n";*/
return N;
}