# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1075247 | 2024-08-25T21:34:51 Z | ArthuroWich | 정렬하기 (IOI15_sorting) | C++17 | 1000 ms | 23224 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; vector<int> e = p; vector<int> co(n, 0); for (int i = 0; i < n; i++) { co[p[i]] = i; } 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({p[i], p[j]}); swap(p[i], p[j]); s++; } } if (swaps.size() > x) { return 0; } while(swaps.size() < x) { swaps.push_back({0, 0}); } for (int i = 0; i < x; i++) { swap(co[e[xy[i].first]], co[e[xy[i].second]]); swap(e[xy[i].first], e[xy[i].second]); auto [x, y] = swaps[i]; swaps[i] = {co[x], co[y]}; swap(e[co[x]], e[co[y]]); swap(co[x], co[y]); } return s <= x; } int findSwapPairs(int n, int A[], int M, int X[], int Y[], int P[], int Q[]) { 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]}); } for (int i = 0; i <= M; i++) { swaps.clear(); if (check(p, i, n)) { ans = swaps; break; } } for (int i = 0; i < ans.size(); i++) { P[i] = ans[i].first; Q[i] = ans[i].second; } return ans.size(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 436 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 436 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 | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 600 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 436 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 428 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 436 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 | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 600 KB | Output is correct |
11 | Correct | 1 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 | 436 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 428 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 3 ms | 860 KB | Output is correct |
22 | Correct | 4 ms | 860 KB | Output is correct |
23 | Correct | 3 ms | 856 KB | Output is correct |
24 | Correct | 3 ms | 860 KB | Output is correct |
25 | Correct | 1 ms | 860 KB | Output is correct |
26 | Correct | 2 ms | 860 KB | Output is correct |
27 | Correct | 2 ms | 860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 600 KB | Output is correct |
2 | Correct | 34 ms | 604 KB | Output is correct |
3 | Correct | 31 ms | 600 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 2 ms | 604 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 9 ms | 520 KB | Output is correct |
8 | Correct | 33 ms | 664 KB | Output is correct |
9 | Correct | 34 ms | 600 KB | Output is correct |
10 | Correct | 45 ms | 604 KB | Output is correct |
11 | Correct | 26 ms | 680 KB | Output is correct |
12 | Correct | 14 ms | 600 KB | Output is correct |
13 | Correct | 21 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 600 KB | Output is correct |
2 | Correct | 34 ms | 604 KB | Output is correct |
3 | Correct | 31 ms | 600 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 2 ms | 604 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 9 ms | 520 KB | Output is correct |
8 | Correct | 33 ms | 664 KB | Output is correct |
9 | Correct | 34 ms | 600 KB | Output is correct |
10 | Correct | 45 ms | 604 KB | Output is correct |
11 | Correct | 26 ms | 680 KB | Output is correct |
12 | Correct | 14 ms | 600 KB | Output is correct |
13 | Correct | 21 ms | 604 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Execution timed out | 1010 ms | 23224 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |