# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039938 | 2024-07-31T12:45:33 Z | Zicrus | Sorting (IOI15_sorting) | C++17 | 94 ms | 756 KB |
#include <bits/stdc++.h> #include "sorting.h" using namespace std; typedef long long ll; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { ll res = 0; vector<ll> s(N); for (int i = 0; i < N; i++) s[i] = S[i]; for (int i = 0; i < M; i++) { swap(s[X[i]], s[Y[i]]); vector<ll> order = s; for (int j = i+1; j < M; j++) { swap(order[X[j]], order[Y[j]]); } int firstOut = -1, id = -1; for (int j = 0; j < N; j++) { if (order[j] != j) { firstOut = order[id = j]; break; } } if (firstOut == -1) { P[res] = Q[res] = 0; res++; } else { ll v = *find(order.begin(), order.end(), id); ll id1 = find(s.begin(), s.end(), firstOut) - s.begin(); ll id2 = find(s.begin(), s.end(), v) - s.begin(); swap(s[id1], s[id2]); P[res] = id1; Q[res] = id2; res++; } firstOut = -1; for (int j = 0; j < N; j++) { if (s[j] != j) { firstOut = s[j]; break; } } if (firstOut == -1) return res; } P[res] = Q[res] = 0; res++; return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 448 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 448 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 604 KB | Output is correct |
21 | Correct | 82 ms | 672 KB | Output is correct |
22 | Correct | 84 ms | 604 KB | Output is correct |
23 | Correct | 93 ms | 680 KB | Output is correct |
24 | Correct | 94 ms | 680 KB | Output is correct |
25 | Correct | 88 ms | 684 KB | Output is correct |
26 | Correct | 79 ms | 756 KB | Output is correct |
27 | Correct | 83 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |