# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
137832 | dolphingarlic | 정렬하기 (IOI15_sorting) | C++14 | 651 ms | 28280 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
#define mid (l+r)/2
using namespace std;
const int inf = 6e5+9;
int n,m,x[inf],y[inf],a[inf],pos[inf],from[inf],origin[inf],posfrom[inf];
bool check(int i,int p[],int q[]){
int l = 0,notvalid = 0;
for(int j=0;j<n;j++){
from[j] = j;
a[j] = origin[j];
p[j] = q[j] = 0;
pos[ a[j] ] = j;
posfrom[ from[j] ] = j;
notvalid += (a[j] != j);
}
//cout<<i<<" "<<notvalid<<endl;
for(int j=i;j>=0;j--){
swap(posfrom[ from[ x[j] ] ] , posfrom[ from[ y[j] ] ]);
swap( from[ x[j] ] , from[ y[j] ] );
}
for(int j=0;j<=i;j++){
swap(pos[ a[ x[j] ] ] , pos[ a[ y[j] ] ]);
swap(posfrom[ from[ x[j] ] ] , posfrom[ from[ y[j] ] ]);
notvalid -= (a[ x[j] ] != x[j]) + (a[ y[j] ] != y[j]);
# | 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... |