Submission #765694

# Submission time Handle Problem Language Result Execution time Memory
765694 2023-06-25T03:15:48 Z normankr07 Bubble Sort 2 (JOI18_bubblesort2) C++14
0 / 100
9000 ms 468 KB
#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;
}

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