# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60075 | Eae02 | 정렬하기 (IOI15_sorting) | C++14 | 1057 ms | 436 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
{
std::vector<int> sorted(S, S + N);
std::sort(all(sorted));
std::vector<int> sInitial(S, S + N);
for (int t = 0; t < M; t++)
{
std::vector<int> finalAccess(N, 0);
for (int i = 0; i < t; i++)
{
finalAccess[X[i]] = i;
finalAccess[Y[i]] = i;
}
std::copy(all(sInitial), S);
int R = 0;
for (; R < t; R++)
{
if (std::equal(S, S + N, sorted.begin()))
return R;
std::swap(S[X[R]], S[Y[R]]);
int index = -1;
for (int i = 0; i < N; i++)
{
if (R >= finalAccess[i] && S[i] != sorted[i])
{
index = i;
break;
}
}
if (index == -1)
{
for (int i = 0; i < N; i++)
{
if (R + 1 == finalAccess[i] && S[i] != sorted[i])
{
index = i;
break;
}
}
if (index == -1 || R + 1 == t)
{
P[R] = Q[R] = 0;
}
else
{
int val = sorted[index];
int target = X[R + 1] == index ? Y[R + 1] : X[R + 1];
auto valIt = std::find(S, S + N, val);
std::swap(S[target], *valIt);
P[R] = target;
Q[R] = valIt - S;
}
}
else
{
int val = sorted[index];
auto valIt = std::find(S, S + N, val);
std::swap(S[index], *valIt);
P[R] = index;
Q[R] = valIt - S;
}
}
}
}
컴파일 시 표준 에러 (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... |