제출 #1168711

#제출 시각아이디문제언어결과실행 시간메모리
1168711anmattroi정렬하기 (IOI15_sorting)C++17
0 / 100
2 ms328 KiB
#include "sorting.h" #include <bits/stdc++.h> #define fi first #define se second using namespace std; using ii = pair<int, int>; int n; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { if (N == 1) return 0; n = N; int nt = 0; int p0 = -1, p1 = -1; for (int i = 0; i < n; i++) if (S[i] == 0) p0 = i; else if (S[i] == 1) p1 = i; if (p0 > 1 && p1 > 1) { P[nt] = 0; Q[nt] = p0; ++nt; P[nt] = 0; Q[nt] = p1; ++nt; } else if (p0 > 1 or p1 > 1) { P[nt] = p0; Q[nt] = p1; ++nt; } for (int i = 2; i < n; i++) if (S[i] != i) for (int j = i+1; j < n; j++) if (S[j] == i) { P[nt] = i; Q[nt] = j; ++nt; } for (int i = 0; i < nt; i++) { swap(X[i], Y[i]); swap(P[i], Q[i]); } if (S[0] != 0) { swap(X[nt], Y[nt]); P[nt] = 0; Q[nt] = 0; ++nt; } return nt; }
#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...