Submission #765698

#TimeUsernameProblemLanguageResultExecution timeMemory
765698normankr07Bubble Sort 2 (JOI18_bubblesort2)C++14
0 / 100
9071 ms468 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) { // cnt--; break; } cnt++; } return cnt; } 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); // Bruteforces for (int i = 0; i < Q; i++) { A[X[i]] = V[i]; answer[i] = bubbleSort(A, A.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...