# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132332 | 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, vector<int> P, vector<int> q)
{
for(int i=0;i<N;i++)
{
v.push_back(make_pair(S[i],i);
}
int c=0;
sort(v.begin(),v.end());
for(int i=0;i<N;i++)
{
if(v[i].second != S[i])continue;
q.push_back(i);
p.push_back(v[i].second());
c++;
}
return c;
}