【Codeforces Round #451 (Div. 2) C】Phone Numbers
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
用map > dic;模拟就好。
后缀。翻转一下就变成前缀了。
两重循环剔除这种情况不输出就好。
【代码】
/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
#include <bits/stdc++.h>
using namespace std;
map <string,vector <string> > dic;
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int T;
cin >> T;
while (T--){
string s;
cin >> s;
int num;
cin >> num;
for (int i = 1;i <= num;i++){
string ts;
cin >> ts;
reverse(ts.begin(),ts.end());
dic[s].push_back(ts);
}
}
cout << dic.size() << endl;
for (auto temp:dic){
vector<string> v = temp.second;
for (int i = 0;i < (int) v.size();i++)
for (int j = 0;j <(int) v.size()-1;j++){
if ((int)v[j].size()>(int)v[j+1].size()){
swap(v[j],v[j+1]);
}
}
set <int> myset;myset.clear();
int len = v.size();
for (int i = 0;i < len;i++)
for (int j = i+1;j < len;j++){
int tlen = v[i].size();
if (v[i]==v[j].substr(0,tlen)){
myset.insert(i);
}
}
cout << temp.first<<' '<<len - (int)myset.size();
for (int i = 0;i < len;i++){
if (myset.count(i)==0){
reverse(v[i].begin(),v[i].end());
cout <<' '<<v[i];
}
}
cout << endl;
}
return 0;
}
【Codeforces Round #451 (Div. 2) C】Phone Numbers的更多相关文章
- 【Codeforces Round #451 (Div. 2) A】Rounding
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟 [代码] /* 1.Shoud it use long long ? 2.Have you ever test several ...
- 【Codeforces Round #451 (Div. 2) B】Proper Nutrition
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 可以直接一层循环枚举. 也可以像我这样用一个数组来存y*b有哪些. 当然.感觉这样做写麻烦了.. [代码] /* 1.Shoud i ...
- 【Codeforces Round #451 (Div. 2) D】Alarm Clock
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 尺取法+二分. 类似滑动窗口. 即左端点为l,右端点为r. 维护a[r]-a[l]+1总是小于等于m的就好. (大于m就右移左端点) ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- Word 操作组件介绍 - Spire.Doc
http://www.cnblogs.com/liqingwen/p/5898368.html
- 英语音乐---一、Scarborough Fair
英语音乐---一.Scarborough Fair 一.总结 一句话总结:斯卡布罗集市 <斯卡布罗集市>诉说了一个缠绵凄美的爱情故事:一个参军的男青年远离自己相爱的姑娘在战争中不幸遇难,但 ...
- 2015合肥网络赛 HDU 5492 Find a path 动归
HDU 5492 Find a path 题意:给你一个矩阵求一个路径使得 最小. 思路: 方法一:数据特别小,直接枚举权值和(n + m - 1) * aver,更新答案. 方法二:用f[i][j] ...
- CORS support in Spring Framework--官方
原文地址:https://spring.io/blog/2015/06/08/cors-support-in-spring-framework For security reasons, browse ...
- OPENCV(4) —— ImgProc
2D图像滤波器基础类BaseFilter:dst(x,y) = F(src(x,y), src(x+1,y)... src(x+wdith-1,y), src(y+1,x)... src(x+widt ...
- SQL语句查询数据库所有表和所有字段的详细信息(包括表描述和字段描述)
select (case then ddd.value else '' end ) as "表名(中文)" --如果表名相同就返回空 , (case then d.name els ...
- GHO文件内IE主页的修改方法
修改方法: 1.先打开映像 GHOSTexp 打开GHO文件 2.提取注册表文件 C:\WINDOWS\SYSTEM32\CONFIG 下就是系统的注册表文件,详细见下 3.打开本地的注册表,加载 ...
- C/C++(C++内存管理,内联函数,类型转换,命名空间,string类)
---恢复内容开始--- 内存管理 new/delete C语言中提供了 malloc 和 free 两个系统函数,#include "stdlib.h"库函数,完成对堆内存的申请 ...
- Tensorflow 函数学习笔记
A: A:## tf.argmax(A, axis).eval() 输出axis维度上最大的数的索引 axis=0:列,axis=1:行 A:## tf.add(a,b) 创建a+b的计算图 A:# ...
- PHP获取一周后的时间戳
echo strtotime("now");//相当于将英文单词now直接等于现在的日期和时间,并把这个日期时间转化为unix时间戳.这个效果跟echo time();一样. ec ...