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.com addresses, 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, addresses ACM.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: addresses polycarp+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
题意:有两种邮件第一种:@bmail 第二种L:@bmain.xxx。对于第一种邮件格式我们要求在@前的 . 忽略,对于@前第一个出现的+后面的内容直到@全部删除,给你n个邮件地址,让你把它们分组,并把每组所包含的
邮件数 和 邮件都打印出来。
分析: map搞。
 /*************************************************************************
> File Name: 365A.cpp
> Author:
> Mail:
> Created Time: 2016年07月29日 星期五 20时54分32秒
************************************************************************/ #include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + ;
map<string,int> mp;
map<string,int> :: iterator it;
int num[maxn];
vector<string> a[maxn];
char cnt[] ={"bmail.com"};
char str[],str1[]; int main()
{
int n;
cin >> n;
int id = ;
mp.clear();
while(n--)
{
cin >> str;
strcpy(str1,str);
int st;
for(int i = ; str1[i]; i++)
{
str1[i] = tolower(str1[i]);
if(str1[i] == '@') st = i;
}
if(strcmp(str1 + st + ,cnt) == )
{
int t = ;
for(int i = ; i< st; i++)
{
if(str1[i] == '.') continue;
if(str1[i] == '+') break;
str1[t++] = str1[i];
}
for(int i = st; str1[i];i++)
{
str1[t++] = str1[i];
}
str1[t] = ;
}
if(mp.find(str1) == mp.end()) mp[str1] = ++id;
int ss = mp[str1];
++num[ss];
a[ss].push_back(str);
}
cout << id << endl;
for(int i = ; i<= id; i++)
{
cout << num[i] << endl;
for(int j = ; j< a[i].size(); j++) cout << ' ' << a[i][j];
cout << endl;
}
return ;
}

codeforces 589A Email Aliases(map)的更多相关文章

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

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

  2. CodeForces 589A Email Aliases (匹配,水题)

    题意:给定于所有的邮箱,都是由login@domain这样的形式构成,而且字符都是不区分大小写的. 我们有一种特殊类型的邮箱——@bmail.com, 这种邮箱除了不区分大小写外—— 1,'@'之前的 ...

  3. 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     ...

  4. CodeForces - 589A

    题目链接:http://codeforces.com/problemset/problem/589/A Polycarp has quite recently learned about email ...

  5. CodeForces - 589A (STL容器的使用)

    Polycarp has quite recently learned about email aliases. Of course, he used to suspect that the case ...

  6. CROC 2016 - Qualification C. Hostname Aliases map

    C. Hostname Aliases 题目连接: http://www.codeforces.com/contest/644/problem/C Description There are some ...

  7. Codeforces 977F - Consecutive Subsequence - [map优化DP]

    题目链接:http://codeforces.com/problemset/problem/977/F 题意: 给定一个长度为 $n$ 的整数序列 $a[1 \sim n]$,要求你找到一个它最长的一 ...

  8. CodeForces 567C. Geometric Progression(map 数学啊)

    题目链接:http://codeforces.com/problemset/problem/567/C C. Geometric Progression time limit per test 1 s ...

  9. Codeforces 567C - Geometric Progression - [map维护]

    题目链接:https://codeforces.com/problemset/problem/567/C 题意: 给出长度为 $n$ 的序列 $a[1:n]$,给出公比 $k$,要求你个给出该序列中, ...

随机推荐

  1. HTTP 文件共享服务器工具 - chfs

    CuteHttpFileServer/chfs是一个免费的.HTTP协议的文件共享服务器,使用浏览器可以快速访问.它具有以下特点: 单个文件,整个软件只有一个可执行程序,无配置文件等其他文件 跨平台运 ...

  2. ElementUi rules表单验证

    ElementUi 表单验证 工作中常用到的JS验证 可以在pattern中书写正则,并且配合elementUI进行表单验证. pattern 属性规定用于验证输入字段的模式.模式指的是正则表达式. ...

  3. 网页里如何使用js屏蔽鼠标右击事件

    图片.png 在后台管理系统里面,遇到了这样的一个问题,右击ztree菜单,弹出修改界面,但是,现在确实这样的,右击默认弹出功能提示的框框,看上去似乎很影响自己想要的功能,只能禁用了,那么,网页里如何 ...

  4. Java多线程-基础知识

    一. 进程是执行中的程序,程序是静态的(我们写完以后不运行就一直放在那里),进程是执行中的程序,是动态概念的.一个进程可以有多个线程. 二. 多线程包含两个或两个以上并发运行的部分,把程序中每个这样并 ...

  5. Java NIO笔记(一):NIO介绍

    Java NIO即Java Non-blocking IO(Java非堵塞I/O),由于是在Jdk1.4之后添加的一套新的操作I/O工具包,所以通常会被叫做Java New IO.NIO是为提供I/O ...

  6. 零基础学python-6.2 共享引用

    这一章节说说共享引用 我们先举一个样例 a=1 b=a 上面的样例就是共享引用,这里我们说说整个过程: 1.创建一个对象1 2.创建一个变量a 3.把a和1所在的内存空间连接起来.就是a引用1 4.a ...

  7. POJ 3254 Corn Fields 状态压缩DP (C++/Java)

    id=3254">http://poj.org/problem? id=3254 题目大意: 一个农民有n行m列的地方,每一个格子用1代表能够种草地,而0不能够.放牛仅仅能在有草地的. ...

  8. Android 手机影音 开发过程记录(六)

    前一篇已经将音乐播放及切换的相关逻辑弄好了,今天主要理一下剩余的部分,包含: 1. 自己定义通知栏的布局及逻辑处理 2. 滚动歌词的绘制 3. 歌词解析 效果图 通知栏 自己定义布局: <?xm ...

  9. 树莓派安装node.js

    因为树莓派是arm架构,node.js上并没有提供arm架构的二进制包下载. 试过使用apt包管理安装和直接node.js源代码编译安装(编译了四五个小时...),都没有成功,报非法指令错误,预计还是 ...

  10. windows电脑空间清理

    最近电脑空间又快满了,想下载一些好电影音频资源都要先临时清理一些文件才行,今天有时间就彻底整理一下,将整理过程及用到的好工具都记录一下,方面下次再遇到问题时可以很方面的参考执行. 1.分析磁盘空间占用 ...