1071. Speech Patterns

#include<algorithm>
#include<unordered_map>
#include<sstream>
#include<string>
#include<iostream>
using namespace std;
typedef const pair<const string,int> E;
typedef unordered_map<string,int> EQ;
int main(){
  string s;
  getline(cin,s);
  for(auto&x:s) x=(isalnum(x)?tolower(x):' ');
  EQ cnt;
  istringstream iss(s);
  while(iss>>s)  ++cnt[s];
  EQ::iterator itor=max_element(cnt.begin(),cnt.end(),[](E&x,E&y){
      return x.second<y.second;}); 
  cout<<itor->first<<' '<<itor->second;
}

你可能感兴趣的:(1071. Speech Patterns)