int main() { int numChefs, numMails; char buff[11], buff2[11]; scanf("%d%d", &numChefs, &numMails); std::string chefName, countryName; while(numChefs--) { //std::cin >> chefName; //std::cin >> countryName; scanf("%s%s", buff, buff2); chefName = buff; countryName = buff2; chef2Country[chefName] = countryName; country2Count[countryName] = 0; chef2Count[chefName] = 0; } while(numMails--) { //std::cin >> chefName; scanf("%s", buff); chefName = buff; chef2Count[chefName]++; country2Count[chef2Country[chefName]]++; } int maxCount = -1; std::string maxCountChef; for(Str2Int::iterator x= chef2Count.begin(); x != chef2Count.end(); x++) { if(x->second > maxCount) { maxCount = x->second; maxCountChef = x->first; } } maxCount = -1; std::string maxCountCountry; for(Str2Int::iterator x= country2Count.begin(); x != country2Count.end(); x++) { if(x->second > maxCount) { maxCount = x->second; maxCountCountry = x->first; } } //Str2Int:: iterator maxChef = std::max_element(chef2Count.begin(), chef2Count.end()); //Str2Int::iterator maxCountry = std::max_element(country2Count.begin(), country2Count.end()); //std::cout << maxCountCountry.c_str() << "\n"; //std::cout << maxCountChef.c_str() << "\n"; printf("%s\n%s\n", maxCountCountry.c_str(), maxCountChef.c_str()); return 0; }
void append(const std::string& word) { std::string lower; cybozu::ToLower(lower, word); Str2Int::const_iterator i = word2id_.find(lower); if (i == word2id_.end()) return; const int id = i->second; if (curTf_ == 0) { tf_.push_back(Int2Int()); curTf_ = &tf_.back(); } (*curTf_)[id]++; if (set_.insert(lower).second) { df_[id]++; } }