没难度上代码。
#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> mp;
struct node {
string s;
int cnt;
};
vector<node> ans;
bool cmp (node a, node b) {
if (a.cnt != b.cnt) return a.cnt > b.cnt;
return a.s < b.s;
}
int main() {
string s;
getline(cin, s);
for (int i = 0; i < s.size(); i++) {
string temp;
while (isalnum(s[i])) {
temp += tolower(s[i++]);
}
if (temp != "") {
mp[temp]++;
}
}
for (auto it : mp)
ans.push_back({it.first, it.second});
sort (ans.begin(), ans.end(), cmp);
cout << ans[0].s << " " << ans[0].cnt;
}