Submission #1347264

#TimeUsernameProblemLanguageResultExecution timeMemory
1347264jahongirBubble Sort 2 (JOI18_bubblesort2)C++20
0 / 100
9091 ms580 KiB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;


vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	int N = (int) A.size();
	int Q = (int) X.size();

	vector<int> res(Q,0);
	
	for(int t = 0; t < Q; t++){
		A[X[t]] = V[t];
		
		auto vec = A;

		bool a = 1;

		for(int i = N-1; i > 0 && a; i--){
			a = 0;

			for(int j = 0; j < i; j++)
				if(vec[j] > vec[j+1]){
					a = 1; swap(vec[j],vec[j+1]);
				}
			
			if(a==0) break;
			res[t]++;
		}

	}

	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...