Submission #70925

#TimeUsernameProblemLanguageResultExecution timeMemory
70925ASG1065Bubble Sort 2 (JOI18_bubblesort2)C++14
17 / 100
9037 ms1716 KiB
#include "bubblesort2.h"
#include<bits/stdc++.h>

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	int n = A.size();
	int q = X.size();
	std::vector<int> answer;
	for (int i = 0; i < q; ++i)
    {
        A[X[i]] = V[i];
        std::vector<int> B = A;
        int ct = 0;
        for (int j = 0; j < n; ++j)
        {
            bool s = false;
            for (int k = 0; k < n-j-1; ++k)
            {
                if (B[k] > B[k+1]) {std::swap(B[k], B[k+1]); s = true;}
            }
            if (!s) {break;}
            ++ct;
        }
        answer.push_back(ct);
    }
    return answer;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...