# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
434634 | dxz05 | 정렬하기 (IOI15_sorting) | C++14 | 4 ms | 588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1024;
int a[MAXN];
vector<pair<int, int>> ans;
void Do(int i, int j){
swap(a[i], a[j]);
ans.emplace_back(i, j);
}
void Do2(){
swap(a[0], a[1]);
}
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
for (int i = 0; i < N; i++) a[i] = S[i];
Do2();
for (int i = 2; i < N; i++){
if (a[i] == 0){
for (int j = 0; j < 2; j++){
if (a[j] > 1){
Do(i, j);
break;
}
}
}
}
for (int i = 2; i < N; i++){
if (a[i] == 1){
Do2();
for (int j = 0; j < 2; j++){
if (a[j] > 1){
Do(i, j);
break;
}
}
}
}
for (int i = 2; i < N; i++){
int j = i;
while (j < N && a[j] != i) j++;
j--;
if (i != j){
Do2();
Do(i, j);
}
}
for (int i = 0; i < 10; i++){
Do2();
Do(0, 1);
}
for (int i = 0; i < ans.size(); i++){
bool ok = true;
for (int j = 0; j < N; j++){
if (S[j] != j) ok = false;
}
if (ok) return i;
P[i] = ans[i].first;
Q[i] = ans[i].second;
swap(S[0], S[1]);
swap(S[P[i]], S[Q[i]]);
}
return ans.size();
}
컴파일 시 표준 에러 (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... |