Description

Polycarp has quite recently learned about email aliases. Of course, he used to suspect that the case of the letters doesn't matter in email addresses. He also learned that a popular mail server in Berland bmail.com ignores dots (characters '.') and all the part of an address from the first character "plus" ('+') to character "at" ('@') in a login part of email addresses.

Formally, any email address in this problem will look like "login@domain", where:

  • a "login" is a non-empty sequence of lowercase and uppercase letters, dots ('.') and pluses ('+'), which starts from a letter;
  • a "domain" is a non-empty sequence of lowercase and uppercase letters and dots, at that the dots split the sequences into non-empty words, consisting only from letters (that is, the "domain" starts from a letter, ends with a letter and doesn't contain two or more consecutive dots).

When you compare the addresses, the case of the characters isn't taken into consideration. Besides, when comparing the bmail.comaddresses, servers ignore the dots in the login and all characters from the first character "plus" ('+') to character "at" ('@') in login part of an email address.

For example, addresses saratov@example.com and SaratoV@Example.Com correspond to the same account. Similarly, addressesACM.ICPC.@bmail.com and A.cmIcpc@Bmail.Com also correspond to the same account (the important thing here is that the domains of these addresses are bmail.com). The next example illustrates the use of character '+' in email address aliases: addressespolycarp+contest@BMAIL.COM, Polycarp@bmail.com and polycarp++acm+icpc@Bmail.Com also correspond to the same account on the server bmail.com. However, addresses a@bmail.com.ru and a+b@bmail.com.ru are not equivalent, because '+' is a special character only for bmail.com addresses.

Polycarp has thousands of records in his address book. Until today, he sincerely thought that that's exactly the number of people around the world that he is communicating to. Now he understands that not always distinct records in the address book represent distinct people.

Help Polycarp bring his notes in order by merging equivalent addresses into groups.

Input

The first line of the input contains a positive integer n(1 ≤ n ≤ 2·104) — the number of email addresses in Polycarp's address book.

The following n lines contain the email addresses, one per line. It is guaranteed that all of them are correct. All the given lines are distinct. The lengths of the addresses are from 3 to 100, inclusive.

Output

Print the number of groups k and then in k lines print the description of every group.

In the i-th line print the number of addresses in the group and all addresses that belong to the i-th group, separated by a space. It is allowed to print the groups and addresses in each group in any order.

Print the email addresses exactly as they were given in the input. Each address should go to exactly one group.

Sample Input

Input
6
ICPC.@bmail.com
p+con+test@BMAIL.COM
P@bmail.com
a@bmail.com.ru
I.cpc@Bmail.Com
a+b@bmail.com.ru
Output
4
2 ICPC.@bmail.com I.cpc@Bmail.Com
2 p+con+test@BMAIL.COM P@bmail.com
1 a@bmail.com.ru
1 a+b@bmail.com.ru 代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
const int MAXN = 2e4+;
const double eps = 1e-;
char str[MAXN];
char S[MAXN];
map <string, int> mp;
vector<string> vec[MAXN];
int main()
{
int n;
while(cin>>n)
{
for(int i=; i<MAXN; i++)
vec[i].clear();
mp.clear();
int tmp = , ans = ;
for(int i=; i<n; i++)
{
cin>>str;
strcpy(S,str);
int len = strlen(str);
for(int ii=; ii<len; ii++)
{
if(str[ii]>='A'&&str[ii]<='Z')
str[ii] = str[ii]+'a'-'A';
if(str[ii] == '@')
tmp = ii;
}
if(strcmp(str+tmp+,"bmail.com")==)
{
int l = ;///变化之后的长度
for(int j=; j<tmp; j++)
{
if(str[j] == '.')
continue;
if(str[j] == '+')
break;
str[l++] = str[j];
}
for(int j=tmp; str[j]; j++)
str[l++] = str[j];
str[l] = '\0';
}
if(mp.find(str) == mp.end())///判断有没有相同
mp[str] = ans++;
int tt = mp[str];
vec[tt].push_back(S);
}
cout<<ans<<endl;
for(int i=; i<ans; i++)
{
cout<<vec[i].size();
for(int j=; j<vec[i].size(); j++)
cout<<" "<<vec[i][j];
puts("");
}
}
return ;
}

map与vector---Email Aliases的更多相关文章

  1. 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest A Email Aliases(模拟STL vector+map)

    Email AliasesCrawling in process... Crawling failed Time Limit:2000MS     Memory Limit:524288KB     ...

  2. codeforces 589A Email Aliases(map)

    Description Polycarp has quite recently learned about email aliases. Of course, he used to suspect t ...

  3. TTTTTTTTTTTTTTTTTT CodeForces 589A Email Aliases 字符串 map

    A - Email Aliases Time Limit:2000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u ...

  4. PAT甲题题解-1022. Digital Library (30)-map映射+vector

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789235.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  5. [uva11991]map和vector的入门

    给你一个长度为n的数组,进行m次询问,每次询问输入k和v,输出第k次出现v时的下标是多少. n<=1e6 用vector动态开空间,map使数值结合.map每次查找效率大约为logn. map的 ...

  6. UVA12096 集合栈计算机(map和vector实现双射关系+集合的交并运算的STL)

    题目大意: 对于一个以集合为元素的栈,初始时栈为空. 输入的命令有如下几种: PUSH:将空集{}压栈 DUP:将栈顶元素复制一份压入栈中 UNION:先进行两次弹栈,将获得的集合A和B取并集,将结果 ...

  7. PAT 1039 Course List for Student (25分) 使用map<string, vector<int>>

    题目 Zhejiang University has 40000 students and provides 2500 courses. Now given the student name list ...

  8. Educational Codeforces Round 108 (Div. 2), C map套vector存储

    地址  Problem - C - Codeforces 题目 题意 一个学校有n个人参加比赛,他们分别属于ui队,每个人的能力值为si 当每个队需要1~n个人的时候,这个学校能参加的人的能力值和最大 ...

  9. c++ map、vector、list

    总体来说,使用map最简单.支持查找,获取下标不存在也不会出错 map是使用rbtree结构, vector是用连续获取内存的方法,类似hash结构.list是链表结构, 不支持下标. map: 支持 ...

  10. map 和 vector 的erase函数说明

    1. map的erase函数使用 这里首先要注意,C++针对map的erase函数有不同的函数原型,这往往是出现问题的关键所在.根据参考文献1: 在C++98中: (1) void erase (it ...

随机推荐

  1. FindProcDLL::FindProc 和 KillProcDLL::KillProc,必须使用WPF x86编译出来的程序

    如果是 WPF 编写的exe,想用NSIS打包. 脚本里面要注意了,如果使用了 FindProcDLL::FindProc 和 KillProcDLL::KillProc, 那么WPF 的编译选项必须 ...

  2. iOS 自定义滑动切换TabBar

    貌似经常会用到,自己整理收藏起来,方便日后查找备用. 效果如图: 由于制作gif,调整了属性,所以看起来的效果不好.如果用默认配置,生成的gif会很大. 制作gif: 1.使用QuickTimePla ...

  3. 通过微信查找SAP TCODE代码

    输入T-CODE查询作用: (包含了16000+ 个SAP T-CODE),扫码关注后可以体验效果 再也不用去记那么多T-CODE用途了 还不试试看 输入关键词:"利润中心" &q ...

  4. [转载]在 JavaScript 中判断“空值”

    http://lync.in/check-empty-value-in-javascript/ 有时候我们会遇到这样的情况:在一些前端控件要提交数据到服务器端的数据验证过程中,需要判断提交的数据是否为 ...

  5. Js 一些方法(一)

    (function ($) { var promoter = promoter || {}; promoter.utils = (function () { var controller = &quo ...

  6. Backbone之旅——Collection and View篇

    上篇文章说了Model,这次说说Collection,collection就是model的集合,用来装载model对象的 定义方法 var Persons = new Backbone.Collect ...

  7. php网页切图/js切图

    PhantomJS抓取网站页面信息以及网站截图 http://phantomjs.org/download.html PHP imagegrabscreen和imagegrabwindow(截取网站缩 ...

  8. BI项目需求分析书-模板

    目录 目录 .............................................................................................. ...

  9. 让我们一起Go(十一)

    前言: 今天又要继续了,当初自己的挖的坑必须得填啊,尽管天气非常滴热,但是丝毫无法阻挡我填坑的热情,那么,我们继续让我们一起Go!!! 定义方法: 这里我们要来看看Golang中的(Methods)方 ...

  10. SNF开发平台WinForm之十-Excel导入-SNF快速开发平台3.3-Spring.Net.Framework

    7.1运行效果: 2.Excel导入开发实现 2.1. 创建窗体,修改命名空间 新增的窗体命名“FrmImport表名”,这个导入窗口比较其它窗口会特殊一些,需要继承BaseFormImport父级窗 ...