# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65679 | mirbek01 | Sorting (IOI15_sorting) | C++17 | 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 "sorting.h"
# include <bits/stdc++.h>
using namespace std;
int findSwapPairs(int n, int ar[], int m, int x[], int y[], int p[], int q[])
{
int sz = 0;
for (int i = 0; i < n; i++)
{
bool fl = true;
for (int j = 0; j < n; j++)
if (ar[j] != j)
fl = false;
if (fl) break;
for (int j = i; j < n; j++)
{
if ( ar[j] == i )
{
swap(ar[j], ar[i]);
p[sz] = i;
q[sz] = j;
sz++;
break;
}
}
}
for(int i = 0; i < n; i ++){
assert(i == ar[i]);
}
assert(sz <= M);
return sz;
}