#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
int findSwapPairs(
int N, int S[], int M, int X[], int Y[], int P[], int Q[]
) {
swap(S[X[0]], S[Y[0]]); // now is our turn
for (int t=0; t<N; t++) {
int permut[N];
for (int i=0; i<N; i++) permut[i] = i;
for (int i=t+1; i<M; i++) {
swap(permut[X[i]], permut[Y[i]]);
}
int a=0, b=0;
for (int i=0; i<N; i++) {
if (S[i] == t) a = i;
}
b = permut[t];
swap(S[a], S[b]);
P[t] = a; Q[t] = b;
swap(S[X[t+1]], S[Y[t+1]]);
}
for (int t=N; t<M; t++) {
P[t] = Q[t] = 0;
}
return M;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |