# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
832590 | aymanrs | 정렬하기 (IOI15_sorting) | C++14 | 484 ms | 480 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
if(is_sorted(S, S+N)) return 0;
int p[N], q[N];
int R, l = 0, r = M-1, m, b = M;
int cp[N];
for(int i = 0;i < N;i++) cp[i] = S[i];
while(l <= r){
R = 0;
for(int i = 0;i < N;i++) S[i] = cp[i];
m = l+r>>1;
for(int i = 0;i <= m;i++){
if(is_sorted(S, S+N)) break;
R++;
swap(S[X[i]], S[Y[i]]);
int opt[N];
for(int j = 0;j<N;j++) opt[j]=j;
for(int j = M-1;j > i;j--) swap(opt[X[j]], opt[Y[j]]);
bool f = false;
for(int j = 0;j < N;j++){
if(S[j] != opt[j]){
f = true;
for(int k = j+1;k < N;k++) {
if(S[k] == opt[j]) {
p[R-1] = j;
q[R-1] = k;
swap(S[j], S[k]);
break;
}
}
break;
}
}
if(!i) p[R-1] = q[R-1] = 0;
}
if(is_sorted(S, S+N)){
for(int i = 0;i < R;i++) {
P[i] = p[i];
Q[i] = q[i];
}
b = R;
r = m-1;
} else l = m+1;
}
return b;
}
컴파일 시 표준 에러 (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... |