【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两种颜色的格子; 让你在这个格子 ...
随机推荐
- webpack03
index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- Lesson 1 Basic Concepts: Part 3
A cheaper option Some people may not want to buy a domain or pay for hosting because they only have ...
- doT.js灵活运用之嵌入使用
基础的base_info_area <div id="base_info_area"></div> <script type="text/h ...
- NET Remoting原理及应用
.NET Remoting原理及应用实例: Remoting:(本文摘自百度百科) 简介: 什么是Remoting,简而言之,我们可以将其看作是一种分布式处理方 式.从微软的产品角度来看 ...
- Java反射异常处理之InvocationTargetException
java.lang.reflect.InvocationTargetException处理办法可能是没有引commons-lang3-3.x.jar包
- Servlet之doPost获取表单参数
/** * 获取表单参数 */ private void readForm() { // TODO Auto-generated method stub Enumeration e = request ...
- codeforces 710A King Moves(水)
output standard output The only king stands on the standard chess board. You are given his position ...
- Sub Thread to update main Thread (UI)
Sub Thread to update main Thread (UI) main Thread : A has Hander.HandleMessage() to process the & ...
- JS实现PC端全兼容复制
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- BZOJ2668: [cqoi2012]交换棋子(费用流)
Description 有一个n行m列的黑白棋盘,你每次可以交换两个相邻格子(相邻是指有公共边或公共顶点)中的棋子,最终达到目标状态.要求第i行第j列的格子只能参与mi,j次交换. Input 第一行 ...