# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69018 | theknife2001 | Sorting (IOI15_sorting) | C++17 | 6 ms | 640 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;
const int N=555;
int b[N];
int n;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
{
n=N;
for(int i=0;i<n;i++)
b[S[i]]=i;
int ans=0;
for(int j=0;j<M;j++)
{
swap(b[S[X[j]]],b[S[Y[j]]]);
swap(S[X[j]],S[Y[j]]);
for(int i=n-1;i>=0;i--)
{
if(S[i]!=i)
{
P[ans]=b[i];
Q[ans]=i;
swap(b[i],b[S[i]]);
swap(S[i],S[b[S[i]]]);
ans++;
break ;
}
else if(i==0)
{
return ans;
}
}
// for(int i=0;i<n;i++)
// cout<<b[i]<<' ';
// cout<<endl;
// for(int i=0;i<n;i++)
// cout<<S[i]<<' ';
// cout<<endl;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |