zawatins-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub zawa-tin/zawatins-library

:heavy_check_mark: test/makebuc.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_A"

#include "../src/template/makebuc.hpp"

#include <iostream>
#include <vector>

int main() {
	int n; std::cin >> n;
	std::vector A(n, 0);
	for (auto& a : A) {
		std::cin >> a;
	}
	auto buc = zawa::makebuc(A, 10001);
	std::vector res(0, 0);
	for (int i = 0 ; i < 10001 ; i++) {
		for (int _ = 0 ; _ < buc[i] ; _++) {
			res.push_back(i);
		}
	}
	for (int i = 0 ; i < n ; i++) {
		std::cout << res[i] << (i + 1 == n ? '\n' : ' ');
	}
}
#line 1 "test/makebuc.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_A"

#line 2 "src/template/makebuc.hpp"

#include <vector>
#include <string>

namespace zawa {

template <class T>
std::vector<int> makebuc(const std::vector<T>& A, const T& sup) {
	std::vector<int> res(sup, 0);
	for (const auto& a : A) {
		res[a]++;
	}
	return res;
}

std::vector<int> makebuc(const std::string& S, bool lower = true) {
	std::vector<int> res(26, 0);
	int minus = (lower ? (int)'a' : (int)'A');
	for (const auto& c : S) {
		res[c - minus]++;
	}
	return res;
}

} // namespace zawa
#line 4 "test/makebuc.test.cpp"

#include <iostream>
#line 7 "test/makebuc.test.cpp"

int main() {
	int n; std::cin >> n;
	std::vector A(n, 0);
	for (auto& a : A) {
		std::cin >> a;
	}
	auto buc = zawa::makebuc(A, 10001);
	std::vector res(0, 0);
	for (int i = 0 ; i < 10001 ; i++) {
		for (int _ = 0 ; _ < buc[i] ; _++) {
			res.push_back(i);
		}
	}
	for (int i = 0 ; i < n ; i++) {
		std::cout << res[i] << (i + 1 == n ? '\n' : ' ');
	}
}
Back to top page