Submission #765688

#TimeUsernameProblemLanguageResultExecution timeMemory
765688normankr07Bubble Sort 2 (JOI18_bubblesort2)C++14
0 / 100
9020 ms724 KiB
#include "bubblesort2.h" using namespace std; int bubbleSort(std::vector<int> &arr, int n) { int cnt = 0; int i, j; bool swapped; for (i = 0; i < n - 1; i++) { swapped = false; for (j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { swap(arr[j], arr[j + 1]); swapped = true; } } if (swapped == false) { break; } cnt++; } return cnt + 1; } std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V) { int Q = X.size(); std::vector<int> answer(Q); for (int j = 0; j < Q; j++) { answer[j] = X[j]; } // Bruteforces for (int i = 0; i < Q; i++) { std::vector<int> cp = A; A[X[i]] = V[i]; answer[i] = bubbleSort(cp, cp.size()); } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...