# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1097835 | michified | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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;
}