ABC155C Poll 题解 (map 遍历) 📅 2026/8/9 2:54:19 题目链接-洛谷 / 题目链接-Atcoder题目大意给你个字符串输出个字符串中出现次数最多的字符串 可能有多个按字典序输出这题思路很简单开一个 mapstring, int 存票数遍历 map 找最大票数再遍历一次如果当前票数等于最大票数就输出Tips:map 其实是一堆 pairfirst 存的是 keysecond 存的是 valueAC Code:#include bits/stdc.h using namespace std; int main() { mapstring, int polls; // 票数 string poll; int n, maxx -1; // n 和最大值 cin n; for(int i 1; i n; i) { cin poll; polls[poll]; // 当前票的票数增加 } for(auto i : polls) // 找最大票数 { maxx max(maxx, i.second); } for(auto i : polls) // 输出 { if(i.second maxx) { cout i.first \n; } } return 0; }