487-3279
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 247781   Accepted: 44015

Description

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2 
D, E, and F map to 3 
G, H, and I map to 4 
J, K, and L map to 5 
M, N, and O map to 6 
P, R, and S map to 7 
T, U, and V map to 8 
W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number.

Input

The input will consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters. 

Output

Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line:

No duplicates.

Sample Input

12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

Sample Output

310-1010 2
487-3279 4
888-4567 3
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
map<string ,int> m;
string str;
vector <string> q;
char readchar(){
char ch;
while(1){
ch=getchar();
if(ch>='A'&&ch<'Q'){
ch=(ch-'A')/3+2+'0';
break;
}
else if(ch>'Q'&&ch<'Z'){
ch=(ch-'A'-1)/3+2+'0';
break;
}
else if(ch<='9'&&ch>='0'){
break;
}
}
return ch;
}
int main(){
int k;
cin>>k;
while(k--){
str="";
for(int i=0;i<7;i++){
str+=readchar();
}
if(m[str]){
m[str]++;
}
else {
m[str]=1;
q.push_back(str);
}
}
sort(q.begin(),q.end()-1);
bool fl=true;
for(vector<string>::iterator i=q.begin();i<q.end();i++){
if(m[*i]>1){
cout<<i->substr(0,3)<<"-"<<i->substr(3,4)<<" "<<m[*i]<<endl;
fl=false;
}
}
if(fl){
cout<<"No duplicates."<<endl;
}
return 0;
}

  

快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0的更多相关文章

  1. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

  2. 快速切题 poj 3026 Borg Maze 最小生成树+bfs prim算法 难度:0

    Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8905   Accepted: 2969 Descrip ...

  3. 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted:  ...

  4. 快速切题 poj 1003 hangover 数学观察 难度:0

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Descr ...

  5. 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0

    Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23033   Accepted: 10612 Descri ...

  6. 快速切题 sgu115. Calendar 模拟 难度:0

    115. Calendar time limit per test: 0.25 sec. memory limit per test: 4096 KB First year of new millen ...

  7. POJ 1094 Sorting It All Out 拓扑排序 难度:0

    http://poj.org/problem?id=1094 #include <cstdio> #include <cstring> #include <vector& ...

  8. POJ 2632 Crashing Robots 模拟 难度:0

    http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorith ...

  9. POJ 1068 Parencodings 模拟 难度:0

    http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...

随机推荐

  1. Docker+.Net Core 的那些事儿-1.准备工作

    1.下载centos 地址:https://www.centos.org/download/ 我使用的是DVD ISO,这么做的目的是为了在之后的docker填坑的路上,方便使用centos中Fire ...

  2. Centos75 解决Nginx出现403 forbidden(13: Permission denied)

    Centos75 新安装的vm,nginx出现403 forbidden 一般为SELinux设置为开启状态(enabled)的原因 切为root ,执行: sed -i 's/SELINUX=enf ...

  3. Send2MyKindle使用说明文档

    软件下载地址为:Send2MyKindle 功能简介 该软件主要功能为在Windows下将Kindle电子书发送到亚马逊中国网站注册的Kindle账户.整个软件界面如下图所示: 使用步骤 使用前的准备 ...

  4. 先记录一下吧 开始的程序 hello!java!

    起床后就跟着老师的教学,也稍微学了一些,刚开始用java. 一堆大小写字母注意不过来,很尴尬. 虽然只是成功了一个"hello java "的简单的不能再简单的小程序,不过还是有点 ...

  5. [洛谷P4918]信仰收集

    题目背景 随着各种势力的迁入,守矢神社丧失了不少信仰现在,为了挽回香火日益惨淡的神社,八坂神奈子派遣神社的风祝早苗去人类村落收集信仰 题目描述 你可以将村落看成一个m个点的有向无环图(编号从1−m), ...

  6. 翻翻git之---丰富多样的路由跳转开源库 ARouter

    转载请注明出处:王亟亟的大牛之路 有一段时间没更新博客了,最近也没学什么新东西,正好组里小伙在做路由跳转的一个"公共库",然后正好最近这样的轮子不少,我也就跟着看看,学习一下人家的 ...

  7. 源码安装GCC-4.9.2

    本文参考:http://cuchadanfan.blog.51cto.com/9940284/1689556  感谢原作者的分享! 首先安装基础包,安装网络依赖的时候要用 [root@localhos ...

  8. Spring中RestTemplate进行Http调用

    Spring中的RestTemplate类源自spring-web,http调用中设置超时时间.设置连接池管理等非常重要,保证了系统的可用性,避免了长时间连接不上或者等待数据返回,拖垮系统. 现贴出工 ...

  9. 统计tophat map上的read数量

    samtools flagstat /SRA111111/SRR111222/accepted_hits.bam 78406056 + 0 in total (QC-passed reads + QC ...

  10. Tornado异步(2)

    Tornado异步 因为epoll主要是用来解决网络IO的并发问题,所以Tornado的异步编程也主要体现在网络IO的异步上,即异步Web请求. 1. tornado.httpclient.Async ...