# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426014 | 2021-06-13T12:59:34 Z | _fractal | Sorting (IOI15_sorting) | C++14 | 131 ms | 412 KB |
#include "sorting.h" #include <cassert> #include <iostream> #include <algorithm> using namespace std; int findSwapPairs(int N, int SS[], int M, int X[], int Y[], int P[], int Q[]) { int A[N], pos[N], S[N]; while (true) { bool F = 1; for (int i = 0; i < N; ++i) A[i] = i, S[i] = SS[i]; for (int i = M - 1; i >= 0; --i) swap(A[X[i]], A[Y[i]]); int r = 0; for (int i = 0; i < M; ++i) { swap(S[X[i]], S[Y[i]]); swap(A[X[i]], A[Y[i]]); for (int j = 0; j < N; ++j) pos[A[j]] = j; for (int j = 0; j < N; ++j) { if (pos[S[j]] != j) { Q[i] = j, P[i] = pos[S[j]]; ++r; break; } } swap(S[Q[i]], S[P[i]]); bool f = 1; for (int i = 1; i < N; ++i) if (S[i - 1] > S[i]) f = 0; if (f && i + 1 != M) { F = 0; break; } } if (F) { return r; } --M; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 131 ms | 312 KB | Output is correct |
11 | Correct | 124 ms | 308 KB | Output is correct |
12 | Correct | 121 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 292 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 131 ms | 312 KB | Output is correct |
11 | Correct | 124 ms | 308 KB | Output is correct |
12 | Correct | 121 ms | 308 KB | Output is correct |
13 | Incorrect | 1 ms | 292 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 412 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 412 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |