제출 #832578

#제출 시각아이디문제언어결과실행 시간메모리
832578aymanrs정렬하기 (IOI15_sorting)C++14
54 / 100
188 ms664 KiB
#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[]) { int R = 0; for(int i = 0;i < M;i++){ if(is_sorted(S, S+N)) return R; 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(!f) P[R-1] = Q[R-1] = 0; } assert(is_sorted(S, S+N)); return R; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...