# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
135792 | amiratou | Sorting (IOI15_sorting) | C++14 | 4 ms | 508 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
map<int,int> pos;
for (int i = 0; i < N; ++i)
pos[S[i]]=i;
int comp=0,idx=0;
for (int i = 2; i < N; ++i)
{
if(pos[i]==i)continue;
//cerr<<X[idx]<<","<<Y[idx++]<<"\n";
//int nb=S[X[idx]],nb2=S[Y[idx]];
swap(pos[S[X[idx]]],pos[S[Y[idx]]]);
swap(S[X[idx]],S[Y[idx++]]);
/*for (int j = 0; j < N; ++j)
cerr<<S[j]<<" ";
cerr<<"\n";*/
P[comp]=pos[i],Q[comp]=i;
pos[S[i]]=pos[i];
pos[i]=i;
swap(S[P[comp]],S[Q[comp]]);
comp++;
}
if(pos[0]!=0){
swap(pos[S[X[idx]]],pos[S[Y[idx]]]);
swap(S[X[idx]],S[Y[idx++]]);
P[comp]=0,Q[comp]=0;
comp++;
if(S[0]==0)return comp;
P[comp]=0,Q[comp]=1;
swap(pos[0],pos[1]);
swap(S[0],S[1]);
comp++;
}
/*for (int i = idx; i < M; ++i)
{
swap(pos[X[i]],pos[Y[i]]);
swap(S[X[i]],S[Y[i]]);
}*/
/*for (int j = 0; j < N; ++j)
cerr<<S[j]<<" ";
cerr<<"\n";*/
return comp;
}
컴파일 시 표준 에러 (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... |