#include "sorting.h"
#include "bits/stdc++.h"
using namespace std;
const int mxN = 2e5 + 7;
int n, m, arr[mxN];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
n = N, m = M;
for (int i = 0; i < n; ++i) {
arr[i] = S[i];
}
int R = 0;
bool ok = false;
for (int ind = 0; ind < m && !ok; ++ind) {
swap(arr[X[ind]], arr[Y[ind]]);
bool stop = false;
for (int i = 0; i < n && !stop; ++i) {
if (ind + 1 < m && (i == X[ind + 1] || i == Y[ind + 1]))
continue;
for (int j = 0; j < n && !stop; ++j) {
if (arr[j] == i && i != j) {
swap(arr[j], arr[i]);
P[ind] = j, Q[ind] = i;
++R;
stop = true;
}
}
}
ok = true;
for (int i = 0; i < n; ++i) {
if (arr[i] != i) {
ok = false;
}
}
if (!stop && ok) {
P[ind] = 0;
Q[ind] = 0;
++R;
}
}
return R;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
400 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
400 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |