이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |