CodeForces 589A Email Aliases (匹配,水题)
题意:给定于所有的邮箱,都是由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 (匹配,水题)的更多相关文章
- codeforces 589A Email Aliases(map)
Description Polycarp has quite recently learned about email aliases. Of course, he used to suspect t ...
- TTTTTTTTTTTTTTTTTT CodeForces 589A Email Aliases 字符串 map
A - Email Aliases Time Limit:2000MS Memory Limit:524288KB 64bit IO Format:%I64d & %I64u ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- UVa 10341 (二分求根) Solve It
很水的一道题,因为你发现这个函数是单调递减的,所以二分法求出函数的根即可. #include <cstdio> #include <cmath> //using namespa ...
- Drupal 7.31版本爆严重SQL注入漏洞
今早有国外安全研究人员在Twitter上曝出了Drupal 7.31版本的最新SQL注入漏洞,并给出了利用测试的EXP代码. 在本地搭建Drupal7.31的环境,经过测试,发现该利用代码可成功执行并 ...
- poj 1364 King(差分约束)
题意(真坑):傻国王只会求和,以及比较大小.阴谋家们想推翻他,于是想坑他,上交了一串长度为n的序列a[1],a[2]...a[n],国王作出m条形如(a[si]+a[si+1]+...+a[si+ni ...
- 设置Android默认锁定屏幕旋转
/********************************************************************************** * 设置Android默认锁定屏 ...
- Java [Leetcode 122]Best Time to Buy and Sell Stock II
题目描述: Say you have an array for which the ith element is the price of a given stock on day i. Design ...
- Windows下FFmpeg快速入门
本系列文章导航 Windows下FFmpeg快速入门 ffmpeg参数解释 mencoder和ffmpeg参数详解(Java处理视频) Java 生成视频缩略图(ffmpeg) 使用ffmpeg进行视 ...
- tencent://message协议
tencent://message协议 |举报|字号 订阅 相信很多朋友在访问别人的博客.网上商城时可能会发现上都有这样的小玩意, 点击下就可以弹出对话框和主人进行对话,而且无需加对方为好友. ...
- ECshop 二次开发模板教程3
<p>商品列表</p> <table width="70%" border="1"> <tr> <td&g ...
- hdu 3746 Cyclic Nacklace(KMP)
题意: 求最少需要在后面补几个字符能凑成两个循环. 分析: 最小循环节的应用,i-next[i]为最小循环节. #include <map> #include <set> #i ...
- DataGrid的打印预览和打印
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System. ...