# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132336 | reda | 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>
using namespace std ;
# include "sorting.h"
vector<pair<int,int>> v;
int findSwapPairs(int N, int S[], int M, int X[], int Y, p[], q[])
{
for(int i=0;i<N;i++)
{
v.push_back(make_pair(S[i],i));
}
int c=0;
sort(v.begin(),v.end());
int i=0,j=0;
while(i<n)
{
if(v[i].first != S[i]){i++;}
else {j++;
q[j]=i;
p[j]=v[i].second;
c++;
i++;
}
}
return c;
}