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 = 2e3 + 10;
int n , ar[N] , pos[N] , m;
int findSwapPairs(int nn, int S[], int mm, int X[], int Y[], int P[], int Q[]) {
n = nn;
m = mm;
for(int i = 0 ; i < n ; i++)
ar[i] = S[i];
int R = 0;
for(int i = 0 ; i < m ; i++)
{
R = i + 1;
P[i] = Q[i] = 0;
swap(ar[X[i]] , ar[Y[i]]);
for(int j = 0 ; j < n ; j++)
pos[ar[j]] = j;
bool flg = false;
for(int j = 2 ; j < n ; j++) if(pos[j] != j)
{
swap(ar[j] , ar[pos[j]]);
P[i] = j;
Q[i] = pos[j];
flg = true;
break;
}
if(flg)
continue;
if(pos[0] != 0)
Q[i] = 1;
break;
}
return R;
}
# | 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... |