제출 #1347274

#제출 시각아이디문제언어결과실행 시간메모리
1347274jahongirBubble Sort 2 (JOI18_bubblesort2)C++20
17 / 100
9092 ms1100 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];

		vector<pair<int,int>> vec(N);
		for(int i = 0; i < N; i++)
			vec[i] = {A[i],i};

		sort(vec.begin(),vec.end());
			
		vector<int> ind(N+1);
		ind[N] = N;

		for(int i = 0; i < N; i++)
			ind[i] = vec[i].second;

		for(; ;){
			vector<int> tmp(N+1);
			tmp[N] = N;
			
			int mn = N;
			for(int i = N-1; i >= 0; i--){
				tmp[i] = max(ind[i],mn)-1;
				mn = min(mn,ind[i]);
			}
			
			if(tmp==ind) break;
			res[t]++;
			ind = tmp;
		}
	}

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