#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 time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9071 ms |
468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |