This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
int solve(int N, vector<int> A) {
int cnt = 0;
while (1) {
bool move = 0;
for (int i = 0; i+1 < N; i++) {
if (A[i] > A[i+1]) {
swap(A[i], A[i+1]);
move = 1;
}
}
if (!move) break;
cnt++;
}
return cnt;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
int N = A.size();
int Q = X.size();
vector<int> ans(Q);
for (int j = 0; j < Q; j++) {
A[X[j]] = V[j];
ans[j] = solve(N, A);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |