# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
654851 | 2022-11-01T19:04:55 Z | benjaminkleyn | 정렬하기 (IOI15_sorting) | C++17 | 203 ms | 19324 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[]) { int lo = 0, hi = M; vector<int> s(N); vector<int> pos(N); vector<pair<int,int>> swaps; while (true) { int mid = (lo + hi) / 2; for (int i = 0; i < N; i++) s[i] = S[i]; for (int i = 0; i < mid; i++) swap(s[X[i]], s[Y[i]]); for (int i = 0; i < N; i++) pos[s[i]] = i; swaps.resize(0); for (int i = 0; i < N; i++) if (s[i] != i) { int x = i, y = pos[i]; swaps.push_back({s[i], i}); swap(s[x], s[y]); pos[s[x]] = x; pos[s[y]] = y; } if (lo == hi) break; if (swaps.size() <= mid) hi = mid; else lo = mid + 1; } for (int i = 0; i < N; i++) pos[S[i]] = i; for (int i = 0; i < swaps.size(); i++) { swap(pos[S[X[i]]], pos[S[Y[i]]]); swap(S[X[i]], S[Y[i]]); P[i] = pos[swaps[i].first], Q[i] = pos[swaps[i].second]; swap(pos[S[P[i]]], pos[S[Q[i]]]); swap(S[P[i]], S[Q[i]]); } for (int i = swaps.size(); i < hi; i++) P[i] = Q[i] = 0; return hi; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 308 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 308 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 292 KB | Output is correct |
19 | Correct | 0 ms | 304 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 436 KB | Output is correct |
23 | Correct | 1 ms | 468 KB | Output is correct |
24 | Correct | 1 ms | 468 KB | Output is correct |
25 | Correct | 1 ms | 428 KB | Output is correct |
26 | Correct | 1 ms | 468 KB | Output is correct |
27 | Correct | 2 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 444 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 2 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 440 KB | Output is correct |
12 | Correct | 1 ms | 468 KB | Output is correct |
13 | Correct | 2 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 444 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 2 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 440 KB | Output is correct |
12 | Correct | 1 ms | 468 KB | Output is correct |
13 | Correct | 2 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 440 KB | Output is correct |
15 | Correct | 159 ms | 17008 KB | Output is correct |
16 | Correct | 172 ms | 17448 KB | Output is correct |
17 | Correct | 182 ms | 18428 KB | Output is correct |
18 | Correct | 70 ms | 17060 KB | Output is correct |
19 | Correct | 138 ms | 18032 KB | Output is correct |
20 | Correct | 139 ms | 18496 KB | Output is correct |
21 | Correct | 143 ms | 18620 KB | Output is correct |
22 | Correct | 154 ms | 13632 KB | Output is correct |
23 | Correct | 194 ms | 19060 KB | Output is correct |
24 | Correct | 173 ms | 18788 KB | Output is correct |
25 | Correct | 183 ms | 18568 KB | Output is correct |
26 | Correct | 139 ms | 17960 KB | Output is correct |
27 | Correct | 125 ms | 17332 KB | Output is correct |
28 | Correct | 183 ms | 18676 KB | Output is correct |
29 | Correct | 172 ms | 18420 KB | Output is correct |
30 | Correct | 101 ms | 16948 KB | Output is correct |
31 | Correct | 177 ms | 18736 KB | Output is correct |
32 | Correct | 181 ms | 18512 KB | Output is correct |
33 | Correct | 203 ms | 18964 KB | Output is correct |
34 | Correct | 189 ms | 18692 KB | Output is correct |
35 | Correct | 144 ms | 17744 KB | Output is correct |
36 | Correct | 58 ms | 16232 KB | Output is correct |
37 | Correct | 200 ms | 19324 KB | Output is correct |
38 | Correct | 196 ms | 18624 KB | Output is correct |
39 | Correct | 191 ms | 18780 KB | Output is correct |