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"
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 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... |