#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <unordered_map>
typedef std::vector<std::string> DType;
typedef std::unordered_map<std::string, std::size_t> MType;
DType MakeVector(std::size_t N,const DType& List, unsigned int S = 0) {
std::minstd_rand mr(S);
std::uniform_int_distribution<std::size_t> ui(0, List.size() - 1);
DType R;
for (std::size_t i = 0; i < N; i++) {
R.push_back(List[ui(mr)]);
}
return R;
}
MType MakeHoge(const DType& D) {
MType R;
for (auto& o : D) {
R[o]++;
}
return R;
}
bool Show(const DType& D,const MType& M) {
for (auto o : D) {
std::cout << o << std::endl;
}
std::cout << std::endl;
for (auto o : M) {
std::cout << o.first << ':' << o.second << std::endl;
}
std::cout << std::endl;
return true;
}
int main() {
DType W = { "hoge","huga","foo","bar" };
DType D;
MType R;
D=MakeVector(16, W);
R = MakeHoge(D);
Show(D, R);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cmFuZG9tPgojaW5jbHVkZSA8dW5vcmRlcmVkX21hcD4KCnR5cGVkZWYgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+IERUeXBlOwp0eXBlZGVmIHN0ZDo6dW5vcmRlcmVkX21hcDxzdGQ6OnN0cmluZywgc3RkOjpzaXplX3Q+IE1UeXBlOwoKRFR5cGUgTWFrZVZlY3RvcihzdGQ6OnNpemVfdCBOLGNvbnN0IERUeXBlJiBMaXN0LCB1bnNpZ25lZCBpbnQgUyA9IDApIHsKCglzdGQ6Om1pbnN0ZF9yYW5kIG1yKFMpOwoJc3RkOjp1bmlmb3JtX2ludF9kaXN0cmlidXRpb248c3RkOjpzaXplX3Q+IHVpKDAsIExpc3Quc2l6ZSgpIC0gMSk7CglEVHlwZSBSOwoJZm9yIChzdGQ6OnNpemVfdCBpID0gMDsgaSA8IE47IGkrKykgewoJCVIucHVzaF9iYWNrKExpc3RbdWkobXIpXSk7Cgl9CglyZXR1cm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