# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075174 | 2024-08-25T19:22:23 Z | ArthuroWich | Sorting (IOI15_sorting) | C++17 | 1 ms | 604 KB |
#include "sorting.h" #include<bits/stdc++.h> using namespace std; vector<pair<int, int>> ans, xy, swaps; bool check(vector<int> p, int x, int n) { int s = 0; for (int i = 0; i < x; i++) { swap(p[xy[i].first], p[xy[i].second]); } for (int i = 0; i < n; i++) { if (p[i] == i) { continue; } while(p[i] != i) { int j = p[i]; swaps.push_back({i, j}); swap(p[i], p[j]); s++; } } while(swaps.size() < x) { swaps.push_back({0, 0}); } return s <= x; } int findSwapPairs(int n, int A[], int M, int X[], int Y[], int P[], int Q[]) { vector<pair<int, int>> ans; vector<int> p(n); for (int i = 0; i < n; i++) { p[i] = A[i]; } for (int i = 0; i < M; i++) { xy.push_back({X[i], Y[i]}); } check(p, M, n); ans = swaps; for (int i = 0; i < ans.size(); i++) { P[i] = ans[i].first; Q[i] = ans[i].second; } return ans.size(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |