# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
421618 | Pbezz | 정렬하기 (IOI15_sorting) | C++14 | 3 ms | 428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN=2e5+5;
const ll INF=1e9+7;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int i,k,j,R=0;
bool ok=true;
for(i=0;i<N;i++){
if(S[i]!=i)ok=false;
}
if(ok)return 0;
if(Y[0]==1){
for(i=N-1;i>=0;i--){//find i, send it to ith position
swap(S[0],S[1]);
ok=true;
for(j=0;j<N;j++){
if(S[j]!=j)ok=false;
}
if(ok){
P[R]=0;
Q[R]=0;
R++;
return R;
}
for(k=0;k<N;k++){
if(S[k]==i)break;
}//cout<<i<<" "<<k<<endl;
if(k!=i){
P[R]=k;
Q[R]=i;
R++;
swap(S[k],S[i]);
ok=true;
for(j=0;j<N;j++){
if(S[j]!=j)ok=false;
}
if(ok){
return R;
}
}else{
swap(S[0],S[1]);
}
}
}else{//his moves are redundant
for(i=N-1;i>=0;i--){//find i, send it to ith position
for(k=0;k<N;k++){
if(S[k]==i)break;
}
if(k!=i){
P[R]=k;
Q[R]=i;
R++;
swap(S[k],S[i]);
ok=true;
for(j=0;j<N;j++){
if(S[j]!=j)ok=false;
}
if(ok){
return R;
}
}
}
/*
for(i=0;i<N;i++){
cout<<S[i]<<" ";
}cout<<endl;*/
//while(R>0&&P[R-1]==Q[R-1])R--;
}
return R;
}
컴파일 시 표준 에러 (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... |