Submission #428035

#TimeUsernameProblemLanguageResultExecution timeMemory
428035haxormanSorting (IOI15_sorting)C++14
20 / 100
10 ms332 KiB
#include "sorting.h" #include "bits/stdc++.h" using namespace std; const int mxN = 2e5 + 7; int n, m, arr[mxN]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { n = N, m = M; for (int i = 0; i < n; ++i) { arr[i] = S[i]; } sort(S, S + n); int R = 0, ind = 0; bool ok = false; for (int iter = 1; iter <= m / n && !ok; ++iter) { swap(arr[X[ind]], arr[Y[ind]]); ok = true; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (arr[j] == S[i] && i != j) { swap(arr[j], arr[i]); P[ind] = j, Q[ind] = i; ++R; ++ind; ok = false; break; } } } } 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...