제출 #1247144

#제출 시각아이디문제언어결과실행 시간메모리
1247144SpyrosAliv정렬하기 (IOI15_sorting)C++20
16 / 100
0 ms328 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; int findSwapPairs(int N, int arr[], int m, int x[], int y[], int p[], int q[]) { int n = N; swap(arr[0], arr[1]); int pos[n]; for (int i = 0; i < n; i++) { pos[arr[i]] = i; } int tot = 0; for (int i = 2; i < n; i++) { if (pos[i] != i) { p[tot] = i; q[tot] = pos[i]; pos[arr[i]] = pos[i]; swap(arr[i], arr[pos[i]]); pos[i] = i; tot++; swap(arr[0], arr[1]); swap(pos[arr[0]], pos[arr[1]]); } } if (arr[0] != 0) { p[tot] = 0; q[tot] = 1; swap(arr[0], arr[1]); tot++; } else { p[tot] = 0; q[tot] = 0; tot++; } return tot; }
#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...