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 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
Hint
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
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
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
/*
不用map,查找的时候会超时的,血的教训
*/
#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
#include<string>
#include<stdio.h>
#define N 20010
using namespace std;
struct node
{
string name,lname;//名字
};
int main()
{
//freopen("in.txt","r",stdin);
int n,i;
node fr[N];
char ch[];
int num[N]={};
map<string,int>mop;
vector<string>v[N];
int ans=;
int len=;
bool visit[N];
scanf("%d",&n);
getchar();
for(int i=;i<n;i++)//处理大小写
{
v[i].clear();
scanf("%s",&ch);
fr[i].name=ch;
fr[i].lname=fr[i].name;
transform(fr[i].lname.begin(), fr[i].lname.end(), fr[i].lname.begin(), ::toupper);
v[i].clear();
//cout<<i<<endl;
string s="";
if(fr[i].lname.size()>=)
s=fr[i].lname.substr(fr[i].lname.size()-,fr[i].lname.size()-);
//cout<<s<<endl;
if(s=="@BMAIL.COM")//特殊邮箱的
{
string str="";
for(int j=;j<fr[i].name.size();j++)
{
if(fr[i].name[j]=='+'||fr[i].name[j]=='@')
break;
if(fr[i].name[j]=='.')
continue;
str+=fr[i].lname[j];
}
fr[i].lname=str;
}//处理完了
if(mop.find(fr[i].lname)==mop.end())mop[fr[i].lname]=len++;
int o=mop[fr[i].lname];
++num[o];
v[o].push_back(fr[i].name);
/*int flag=0;
for(int j=0;j<len;j++)//寻找的这个地方超时
{
if(fr[i].lname==fr[j].lname)
{
v[j].push_back(fr[i].name);
flag=1;
visit[i]=false;
}
}
if(flag==0)
{
v[len++].push_back(fr[i].name);
ans++;
}*/
}
printf("%d\n",len);
for(int i=;i<len;i++)
{
printf("%d",num[i]);
for(int j=;j<v[i].size();j++)
{
printf(" %s",v[i][j].c_str());
}
printf("\n");
}
return ;
}
2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest A Email Aliases(模拟STL vector+map)的更多相关文章
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
- codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
A. Find a Number 找到一个树,可以被d整除,且数字和为s 记忆化搜索 static class S{ int mod,s; String str; public S(int mod, ...
- 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)
i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) Solution
A. Find a Number Solved By 2017212212083 题意:$找一个最小的n使得n % d == 0 并且 n 的每一位数字加起来之和为s$ 思路: 定义一个二元组$< ...
- 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing
[链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...
随机推荐
- JS--微信浏览器复制到剪贴板实现
由于太忙很久没写博客了,如有错误遗漏,请指出,感谢! 首先这里要注意,是微信浏览器下的解决方案,其他浏览器请自行测试. 先说复制到剪贴板主要有什么使用场景: 优惠券优惠码,需要用户复制 淘宝商品,需要 ...
- Java 基础语法
一.关键字 定义:被 Java 赋予特殊含义的单词. 特点:基本上都是英文小写. 用于定义数据类型的关键字 基本数据类型 整数型(默认为 int) byte(8 位,1 字节,默认值是 0,最大存储数 ...
- spring 内部工作机制(二)
本章节讲Spring容器从加载配置文件到创建出一个完整Bean的作业流程及参与的角色. Spring 启动时读取应用程序提供的Bean配置信息,并在Spring容器中生成一份相应的Bean配置注册表, ...
- python下selenium测试报告整合
使用过一段时间的Robot Framework测试框架,测试之前需要先搭环境,需要安装的东西很多,这一点个人有些排斥. 每一个测试内容对应一个Test_Case,Robot有自己语法格式,如判断.循环 ...
- Unity 使用 陀螺仪 实现 《王者荣耀》 登入界面 背景动态效果
在 <王者荣耀> 登入界面 左右上下晃动手机(有些手机不支持)可以看到背景在变化 我使用的是iPhone SE 效果如下: 对比两张图片的左下角 可以看到差异 至于为什么要这么做: 1.使 ...
- Java简单工厂模式以及来自lambda的优化
前言 设计模式是软件工程中一些问题的统一解决方案的模型,它的出现是为了解决一些普遍存在的,却不能被语言特性直接解决的问题,随着软件工程的发展,设计模式也会不断的进行更新,本文介绍的是经典设计模式 ...
- 双11电商剁手节,最全的H5互动营销案例合集
距离双11不足一个月! 是否准备好为双十一疯狂剁手! 自从天猫2009年首创双11购物节以来双十一不仅成为了消费者的"剁手日" 更是每年企业营销的"狂欢节" 各 ...
- win10 uwp 无法附加到CoreCLR
本文说的是在vs调试无法附加到CoreCLR.拒绝访问.已经如何去解决,可能带有一定的主观性和局限性,说的东西可能不对或者不符合每个人的预期.如果觉得我有讲的不对的,就多多包含,或者直接关掉这篇文章, ...
- JS前端三维地球渲染——中国各城市航空路线展示
前言 我还从来没有写过有关纯JS的文章(上次的矢量瓦片展示除外,相对较简单.),自己也学习过JS.CSS等前端知识,了解JQuery.React等框架,但是自己艺术天分实在不过关,不太喜欢前端设计,比 ...
- Linux入门(16)——Ubuntu16.04下配置sublime text 3使用markdown
sublime text 3安装两个插件: MarkDown Editing OmniMarkupPreviewer 有的人使用 MarkDown Editing markdownpreviewer ...