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;
int tmp[20010];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
for(int i = 0; i < M; i++)
swap(S[X[i]], S[Y[i]]);
int cur = 0, R = 0;
for(int i = 0; i < N; ) {
if(S[i] == i) { i++; continue; }
int p = i, q = S[i];
// for(int j = M-1; j > cur; j--) {
// if((X[j] == p && Y[j] == q) || (X[j] == q && Y[j] == p)) swap(p, q);
// else {
// if(X[j] == p) p = Y[j];
// else if(Y[j] == p) p = X[j];
// if(X[j] == q) q = Y[j];
// else if(Y[j] == q) q = X[j];
// }
// }
P[R] = p, Q[R] = q;
R++; cur++;
swap(S[i], S[S[i]]);
}
// while(R < M) {
// P[R] = Q[R] = 0;
// R++;
// }
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... |