제출 #1123991

#제출 시각아이디문제언어결과실행 시간메모리
1123991allin27x정렬하기 (IOI15_sorting)C++17
54 / 100
27 ms612 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[]) { vector<int> a(n); iota(a.begin(), a.end(), 0); for (int i=m-1; i>=0; i--) swap(a[x[i]], a[y[i]]); for (int ind=0; ind<m; ind++) { int f =0; for (int i=0; i<n; i++) if (s[i] != i) f++; if (!f) return ind; p[ind] = 0; q[ind] = 0; swap(a[x[ind]], a[y[ind]]); swap(s[x[ind]], s[y[ind]]); f = 0; for (int i=0; i<n; i++) { if (f) break; if (a[i] != s[i]) { for (int j=0; j<n; j++) { if (a[j] == s[i]) { p[ind] = i; q[ind] = j; swap(s[i], s[j]); f = 1; break; } } } } } return m; }
#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...