Submission #764730

#TimeUsernameProblemLanguageResultExecution timeMemory
764730SanguineChameleonSorting (IOI15_sorting)C++17
36 / 100
49 ms900 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; mt19937 gen(64920); int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int len = 0; for (int i = 0; ; i++) { bool ok = true; for (int j = 0; j < N; j++) { if (S[j] != j) { ok = false; break; } } if (ok) { return len; } assert(i < M); swap(S[X[i]], S[Y[i]]); vector<int> wrong; for (int j = 0; j < N; j++) { if (S[j] != j) { wrong.push_back(j); } } if (wrong.empty()) { P[len] = 0; Q[len] = 0; } else { shuffle(wrong.begin(), wrong.end(), gen); P[len] = wrong[0]; for (int j = 0; j < N; j++) { if (S[j] == wrong[0]) { Q[len] = j; break; } } } swap(S[P[len]], S[Q[len]]); len++; } }
#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...