# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1097835 | 2024-10-08T10:04:18 Z | michified | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 0 ms | 0 KB |
vector<int> countScans(vector<int> a, vector<int> x, vector<int> v) { vector<int> ans; for (int i = 0; i < x.size(); i++) { vector<int> tmp = a; tmp[x[i]] = v[i]; int passes = 0; bool finished; for (int i = 0; i < a.size(); i++) { finished = true; for (int j = 1; j < a.size(); j++) { if (tmp[j - 1] > tmp[j]) { swap(tmp[j - 1], tmp[j]); finished = false; } } if (not finished) passes++; else break; } ans.push_back(passes); } return ans; }