#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <random>
std::string MakeData(std::size_t N){
std::random_device RD;
std::mt19937 MT(RD());
//std::uniform_int_distribution<int> uid('a', 'z');
std::string Ch = "abcdefghijklnmopqrstuvwxyz";
std::string R;
for (size_t i = 0; i < N; i++)
{
R += Ch[MT()% Ch.size()];//あえて質の悪い採取方法をとっている。一様乱数が欲しかったらこういう書き方をしてはいけない。
}
return R;
}
std::pair<int,std::vector<char>> MakeHoge(std::string str){
std::map<char, int> M;
std::map<int, std::vector<char>> MV;
for (auto& o : str)M[o]++;
for (auto&o : M)MV[o.second].push_back(o.first);
return *(MV.rbegin());
}
bool Show(std::pair<int,std::vector<char>>& P,std::string str){
std::cout << "RESULT:"<<str<<" -> "<<P.first<<'@';
for (auto& o : P.second) std::cout << o << ',';
std::cout << std::endl;
return 0;
}
int main(){
std::string str;
std::pair<int, std::vector<char>> P;
str = "aabaabbab";
P = MakeHoge(str);
Show(P,str);
str = MakeData(27);
P = MakeHoge(str);
Show(P,str);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cmFuZG9tPgoKc3RkOjpzdHJpbmcgTWFrZURhdGEoc3RkOjpzaXplX3QgTil7CglzdGQ6OnJhbmRvbV9kZXZpY2UgUkQ7CglzdGQ6Om10MTk5MzcgTVQoUkQoKSk7CgkvL3N0ZDo6dW5pZm9ybV9pbnRfZGlzdHJpYnV0aW9uPGludD4gdWlkKCdhJywgJ3onKTsKCglzdGQ6OnN0cmluZyBDaCA9ICJhYmNkZWZnaGlqa2xubW9wcXJzdHV2d3h5eiI7CgoJc3RkOjpzdHJpbmcgUjsKCglmb3IgKHNpemVfdCBpID0gMDsgaSA8IE47IGkrKykKCXsKCQlSICs9IENoW01UKCklIENoLnNpemUoKV07Ly/jgYLjgYjjgabos6rjga7mgqrjgYTmjqHlj5bml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