/*
zoj_1159 字符串处理
简单题。。但是很坑爹啊。。我居然为它断送了一个晚上。。悲剧。。
早上很快写好的代码没过检查了一晚上都木有过。。居然就是因为几行
代码的顺序~~~~(>_<)~~~~
xsbailong吸取教训啊!!!
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
string num[100001];
map <char,char>mymap;
string change( string s )
{
int i;
string ns;
ns="";
for( i=0;i<s.size();i++ )
{
if( s[i]>='A' && s[i]<='Z' )
{
if( ns.size()==3 ) //这边的代码顺序无比重要,一定要跟下个else if里一样!!!
ns+='-';
ns+=mymap[ s[i] ];
}
else if( s[i]>='0' && s[i]<='9' )
{
if( ns.size()==3 ) //因为if和else if里边的顺序不一样,断送了一个晚上啊啊啊!!!
ns+='-';
ns+=s[i];
}
}
return ns;
}
int main()
{
int T,n,i,j,times,first;
string s;
bool nothing;
//freopen( "a.txt","r",stdin );
mymap['A']='2'; mymap['B']='2'; mymap['C']='2'; mymap['D']='3';
mymap['E']='3'; mymap['F']='3'; mymap['G']='4'; mymap['H']='4';
mymap['I']='4'; mymap['J']='5'; mymap['K']='5'; mymap['L']='5';
mymap['M']='6'; mymap['N']='6'; mymap['O']='6'; mymap['P']='7';
mymap['R']='7'; mymap['S']='7'; mymap['T']='8'; mymap['U']='8';
mymap['V']='8'; mymap['W']='9'; mymap['X']='9'; mymap['Y']='9';
cin>>T;
first=1;
while( T-- )
{
cin>>n;
for( i=0;i<n;i++ )
{
cin>>s;
num[i]=change(s);
}
sort( num,num+n );
num[n]="#";
if( first!=1 ) cout<<endl;
nothing=true;
times=1;
for( i=1;i<n;i++ )
{
if( num[i]==num[i+1] )
{
times++;
}
else
{
if( times>1 )
{
cout<<num[i]<<" "<<times<<endl;
times=1;
nothing=false;
}
}
}
if( nothing ) cout<<"No duplicates.\n";
first++;
}
return 0;
}
队里讨论了一下,决定大家都开博,更好的互相鼓励喽。。所以抛弃了sina的博客,在csdn开始新的征程,一切从头开始!!
xsbailong,加油啊!!Justey,加油↖(^ω^)↗