#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
bool check(char c){
if(c>='A'&&c<='Z') return true;
if(c>='0'&&c<='9') return true;
if(c>='a'&&c<='z') return true;
return false;
}
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif // LOCAL
map<string,int> cnt;
string str;
getline(cin,str);
int i=0;
while(i<str.length()){
string word;
while(i<str.length()&&check(str[i])==true){
if(str[i]>='A'&&str[i]<='Z') str[i]+=32;
word+=str[i];
i++;
}
if(word!=""){
if(cnt.find(word)==cnt.end())cnt[word]=1;
else cnt[word]++;
}
while(i<str.length()&&check(str[i])==false)i++;
}
string ans;
int MAX=0;
for(map<string,int>::iterator it = cnt.begin();it!=cnt.end();it++){
//cout<<it->second<<it->first<<endl;
if(it->second>MAX){
MAX=it->second;
ans=it->first;
}
}
cout<<ans<<" "<<MAX<<endl;
return 0;
}
【PAT】1071. Speech Patterns
最新推荐文章于 2021-08-16 22:44:25 发布