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

这种邮箱除了不区分大小写外—— 1,'@'之前的'.',有等同于无 2,'@'之前的第一个'+'之后的字符可以忽略不计 然后其他字符相同的被认定为邮箱相同。

现在给你 n 个邮箱,让你输出每个邮箱出现的次数与所有这个邮箱的原始串。

析:没什么好说的,就是先判断不是@bmail.com,然后再按要求去点,去+和@之间的值,然后一个一个的比较即可,这个题有坑,第一次WA在第54组数据上了,
就是我把@后面的点去了,这个是不能去的,别的都正常。后来我看这个总数据,一共就54组。。。。。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <stack>
using namespace std ; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 2e4 + 5;
const int mod = 1e9 + 7;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
int n, m;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
struct node{
string s;
string chage;
int id;
};
node a[maxn];
bool cmp(const node &lhs, const node &rhs){
return lhs.chage < rhs.chage || (lhs.chage == rhs.chage && lhs.id < rhs.id);
}
bool cmp1(const node &lhs, const node &rhs){
return lhs.id < rhs.id;
}
vector<int> ans[maxn]; int main(){
while(scanf("%d", &n) == 1){
string s;
for(int i = 0; i < n; ++i){
cin >> a[i].s;
a[i].id = i;
ans[i].clear();
}
for(int i = 0; i < n; ++i){
string t;
if(a[i].s.size() < 10) ;
else{
t = a[i].s.substr(a[i].s.size()-10, 10);
for(int i = 0; i < 10; ++i)
t[i] = towlower(t[i]);
} if(t == "@bmail.com"){
bool ok = false;
bool ok1 = false;
for(int j = 0; j < a[i].s.size(); ++j){
if(a[i].s[j] == '@') ok = false, ok1 = true;
else if(a[i].s[j] == '+') ok = true;
if((a[i].s[j] == '.' && !ok1) || ok) continue;
a[i].chage.push_back(towlower(a[i].s[j]));
} }
else{
for(int j = 0; j < a[i].s.size(); ++j){
a[i].chage.push_back(towlower(a[i].s[j]));
}
}
}
sort(a, a+n, cmp);
int cnt = 0;
ans[0].push_back(a[0].id);
for(int i = 1; i < n; ++i){
if(a[i].chage == a[i-1].chage) ans[cnt].push_back(a[i].id);
else ans[++cnt].push_back(a[i].id);
} sort(a, a+n, cmp1);
printf("%d\n", cnt+1);
for(int i = 0; i <= cnt; ++i){
printf("%d", ans[i].size());
for(int j = 0; j < ans[i].size(); ++j){
printf(" %s", a[ans[i][j]].s.c_str());
}
printf("\n");
}
}
return 0;
}

CodeForces 589A Email Aliases (匹配,水题)的更多相关文章

  1. codeforces 589A Email Aliases(map)

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

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

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

  3. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  5. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  6. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  7. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  8. codeforces 710A A. King Moves(水题)

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

  9. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. 真正解决ASP.NET每一个页面首次访问超级慢的问题 (转载)

    原文:http://www.afuhao.com/article_articleId-219.shtml 摘要:ASP.NET页面首次打开很慢,但别的页面如果没有访问过,去访问也会慢.你也许认为它是在 ...

  2. UVa 11389 (贪心) The Bus Driver Problem

    题意: 有司机,下午路线,晚上路线各n个.给每个司机恰好分配一个下午路线和晚上路线. 给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d×r. 问如何分配路线才能使加班费最少. 分析: 感 ...

  3. 好用的工具之一 ---- Sublime Text

    官网地址和详细解释:http://www.sublimetext.com/ 异次元的一些更详细的个人体验细节:http://www.iplaysoft.com/sublimetext.html

  4. Asp.Net操作FTP方法

    将用户上传的附件(文件.图片等)通过FTP方式传送到另外一台服务器上,从而缓解服务器压力 1.相关的文章如下: Discuz!NT中远程附件的功能实现[FTP协议] http://www.cnblog ...

  5. LeetCode: Edit Distance && 子序列题集

    Title: Given two words word1 and word2, find the minimum number of steps required to convert word1 t ...

  6. liunx下mysql数据库使用之三范式,关系模型设计注意项,安装目录结构

    数据库的三范式第一范式===>每行记录的属性,是原子的,拆到不可拆为止.===>例如:一个人的籍贯,可以拆分为,省,市,县,乡,村 第二范式===>每行记录的非主属性(非主键属性), ...

  7. 最简单的基于FFMPEG的转码程序

    本文介绍一个简单的基于FFmpeg的转码器.它可以将一种视频格式(包括封转格式和编码格式)转换为另一种视频格式.转码器在视音频编解码处理的程序中,属于一个比较复杂的东西.因为它结合了视频的解码和编码. ...

  8. 【已解决】Android ADT中增大AVD内存后无法启动:emulator failed to allocate memory 8

    [问题] 折腾: [已解决]Android ADT中增大AVD内存后无法启动:emulator failed to allocate memory 8 过程中,增大对应AVD的内存为2G后,结果无法启 ...

  9. ASP.NET MVC+Bootstrap个人博客之修复UEditor编辑时Bug(四)

    我的个人博客站在使用百度富文本编辑器UEditor修改文章时,遇到了一些问题,(不知是bug,还是我没有配置好).但总算找到了解决方法,在此记录下来. 小站首页文章列表显示为(显示去除HTML标签后的 ...

  10. POJ 1251 Jungle Roads

    题意:嗯……没看题……看了眼图……求个最小生成树. 解法:kruskal. 代码: #include<stdio.h> #include<iostream> #include& ...