# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
320711 | knon0501 | 정렬하기 (IOI15_sorting) | C++14 | 3 ms | 620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int MX=2e5+5;
int a[MX];
int b[MX];
int c[MX];
int d[MX];
int dd[MX];
int e[MX];
int p[MX];
int q[MX];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
P[0] = 0;
Q[0] = 0;
int i,j,k;
int ret=N;
int lef=0;
int rig=N-1;
while(rig>=lef){
int mid=(lef+rig)/2;
for(i=0 ; i<N ; i++){
a[i]=b[i]=S[i];
e[a[i]]=i;
}
for(i=0 ; i<mid ; i++){
swap(b[X[i]],b[Y[i]]);
}
for(i=0 ; i<N ; i++)
c[b[i]]=i;
for(i=0 ; i<N ; i++)
d[i]=c[a[i]],dd[c[a[i]]]=i;
int j=0;
for(i=0 ; i<mid ; i++){
swap(dd[d[X[i]]],dd[d[Y[i]]]);
swap(e[a[X[i]]],e[a[Y[i]]]);
swap(d[X[i]],d[Y[i]]);
swap(a[X[i]],a[Y[i]]);
while(j<N && e[j]==dd[j]){
j++;
}
if(j<N){
int k=a[dd[j]];
p[i]=e[j];
q[i]=dd[j];
swap(a[e[j]],a[dd[j]]);
swap(e[j],e[k]);
}
}
int isok=1;
for(i=0 ; i<N ; i++){
if(i!=a[i])isok=0;
}
if(isok==1){
rig=mid-1;
ret=mid;
for(i=0 ; i<mid ; i++)
{
P[i]=p[i];
Q[i]=q[i];
}
}
else
lef=mid+1;
}
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... |