| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 707037 | marvinthang | 정렬하기 (IOI15_sorting) | C++17 | 197 ms | 12476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
auto check = [&] (int r, bool trace = false) {
vector <int> perm(S, S + N);
REP(i, r) swap(perm[X[i]], perm[Y[i]]);
vector <int> pos(N);
REP(i, N) pos[perm[i]] = i;
vector <pair <int, int>> swaps;
auto __swap = [&] (int i, int j) {
swap(perm[i], perm[j]);
swap(pos[perm[i]], pos[perm[j]]);
};
REP(i, N) {
if (perm[i] != i) {
swaps.push_back(make_pair(perm[i], i));
__swap(i, pos[i]);
}
}
if (!trace) return swaps.size() <= r;
while (swaps.size() < r) swaps.push_back(make_pair(0, 0));
copy(S, S + N, perm.begin());
REP(i, N) pos[perm[i]] = i;
REP(i, r) {
__swap(X[i], Y[i]);
P[i] = pos[swaps[i].fi];
Q[i] = pos[swaps[i].se];
__swap(P[i], Q[i]);
}
return true;
};
int l = 0, r = N;
while (l < r) {
int m = l + r >> 1;
if (check(m)) r = m;
else l = m + 1;
}
check(l, true);
return l;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
