This documentation is automatically generated by online-judge-tools/verification-helper
#include "src/template/makebuc.hpp"
入力で与えた列 $A$ に対して $B_i\ =\ \text{cnt} (i)$ を満たす $B$ を生成して返す。ここで $\text{cnt}(i)$ とは $A_j\ =\ i$ を満たす $j$ の数とする。
関数
std::vector<int> zawa::makebuc<T>(const std::vector<T>& A, const T& sup)
T
はint
以外での使用を想定されていませんsup
はバケットのサイズであり、 $\max(A)$ より真に大きい値である必要があります。std::vector<int> zawa::makebuc(const std::string& S, bool lower = true)
lower
にfalse
を入れてくださいstd::map<T, int>
でも返せるようにする#pragma once
#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 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