题目大意:
将一些邮箱地址分类,bmail.com有特殊的要求,其他邮箱的大小字母视为一样。
解题思路:
简单模拟。
#include "iostream"
#include "cstdio"
#include "string"
#include "string.h"
#include "algorithm"
#include "cctype"
#include "vector"
#include "map"
using namespace std;
int n,k,num=0;
string sp="bmail.com";
map<string,vector<string>>mp;
vector<string>type;
int main(int argc, char* argv[])
{
scanf("%d",&n);
string str,change,left,right;
for(int i=0;i<n;i++)
{
cin>>str;
change=str;
for(int j=0;j<change.length();j++)
{
if(change[j]=='@')
k=j;
if(isalpha(change[j])==1)
change[j]+='a'-'A';
}
right=change.substr(k+1);
left="";
if(right==sp)
{
for(int i=0;i<k;i++)
{
if(change[i]=='.')
continue;
else if(change[i]=='+')
break;
else
left+=change[i];
}
}
else
for(int i=0;i<k;i++)
left+=change[i];
change=left+'@'+right;
if(!mp.count(change))
{
type.push_back(change);
num++;
}
mp[change].push_back(str);
}
printf("%d\n",num);
for(int i=0;i<type.size();i++)
{
printf("%d ",mp[type[i]].size());
for(int j=0;j<mp[type[i]].size();j++)
cout<<" "<<mp[type[i]][j];
printf("\n");
}
return 0;
}