PersonalCorpus 版 (精华区)
40962 2002-10-12 13:04:17 Accepted
1159 C++ 00:02.42 1768K Big Guava
int sort_function( const void *a, const void *b)
{
return memcmp(a,b,7);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\uva\\input755.txt","r",stdin);
freopen("c:\\uva\\output755.txt","w",stdout);
#endif
int i,j,k,n,max,fin;
char s[100];
char t[100000][7];
scanf("%d\n",&n);
while(n>0) {
n--;
scanf("%d\n",&max);
for (i=0;i<max;i++) {
gets(s); k=0;
for (j=0;j<7;j++) {
while (s[k]=='-') k++;
switch (s[k]) {
case 'A' : t[i][j]='2'; break;
case 'B' : t[i][j]='2'; break;
case 'C' : t[i][j]='2'; break;
case 'D' : t[i][j]='3'; break;
case 'E' : t[i][j]='3'; break;
case 'F' : t[i][j]='3'; break;
case 'G' : t[i][j]='4'; break;
case 'H' : t[i][j]='4'; break;
case 'I' : t[i][j]='4'; break;
case 'J' : t[i][j]='5'; break;
case 'K' : t[i][j]='5'; break;
case 'L' : t[i][j]='5'; break;
case 'M' : t[i][j]='6'; break;
case 'N' : t[i][j]='6'; break;
case 'O' : t[i][j]='6'; break;
case 'P' : t[i][j]='7'; break;
case 'R' : t[i][j]='7'; break;
case 'S' : t[i][j]='7'; break;
case 'T' : t[i][j]='8'; break;
case 'U' : t[i][j]='8'; break;
case 'V' : t[i][j]='8'; break;
case 'W' : t[i][j]='9'; break;
case 'X' : t[i][j]='9'; break;
case 'Y' : t[i][j]='9'; break;
default : t[i][j]=s[k];
}
k++;
}
}
qsort((void *)t, max, 7, sort_function);
j=0; k=1; fin=0;
for (i=1;i<max;i++)
if (memcmp(t[i],t[j],7)==0) k++; else {
if (k>1) {
printf("%c%c%c-%c%c%c%c %d\n",t[j][0],t[j][1],
t[j][2]
,t[j][3],t[j][4],t[j][5],t[j][6],k);
fin=1;
}
j=i;k=1;
}
if (k>1) {
printf("%c%c%c-%c%c%c%c %d\n",t[j][0],t[j][1],t[j][2]
,t[j][3],t[j][4],t[j][5],t[j][6],k);
fin=1;
}
if (fin==0) printf("No duplicates.\n");
if (n>0) printf("\n");
gets(s);
}
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.197毫秒