# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
426060 | _fractal | 정렬하기 (IOI15_sorting) | C++14 | 1087 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <iostream>
#include <algorithm>
using namespace std;
int findSwapPairs(int N, int SS[], int M, int X[], int Y[], int P[], int Q[]) {
int A[N], pos[N], S[N], L[M], R[M];
int tl = 0, tr = M - 1, ret = (1<<30);
for (int tm = 0; tm < M; ++tm) {
for (int i = 0; i < N; ++i)
A[i] = i, S[i] = SS[i];
for (int i = tm; i >= 0; --i)
swap(A[X[i]], A[Y[i]]);
int ans = -1;
for (int i = 0; i <= tm; ++i) {
P[i] = Q[i] = 0;
bool f = 1;
for (int j = 1; j < N; ++j)
if (S[j - 1] > S[j])
f = 0;
if (f) {
ans = i;
break;
}
swap(S[X[i]], S[Y[i]]);
swap(A[X[i]], A[Y[i]]);
f = 1;
for (int j = 1; j < N; ++j)
if (S[j - 1] > S[j])
f = 0;
if (f) {
ans = i + 1;
break;
}
for (int j = 0; j < N; ++j)
pos[A[j]] = j;
for (int j = 0; j < N; ++j) {
if (pos[S[j]] != j) {
Q[i] = j, P[i] = pos[S[j]];
break;
}
}
swap(S[Q[i]], S[P[i]]);
}
if (ans != -1) ans = tm;
if (ret > ans) {
ret = ans;
for (int i = 0; i < ret; ++i)
L[i] = Q[i], R[i] = P[i];
}
}
for (int i = 0; i < ret; ret++)
Q[i] = L[i], P[i] = R[i];
return ret;
}
컴파일 시 표준 에러 (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... |