OpenJudge

测试都过了,超时问题也解决了,可还是Wrong Answer,求高手赐教

  • 1henr1
    1henr1 12.9.20 回复

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>

    char tel[100002][30],decode[100002][8];
    char now[8],temp[8];

    int cmp(const void* _a,const void* _b)
    {
    char* a =(char*) _a;
    char* b =(char*) _b;
    return strcmp(a,b);
    }

    int main()
    {
    int i,n,k,j,l,flag;
    scanf ("%d",&n);
    for (i=0;i<n;i++)
    {
    scanf("%s",tel[i]);
    l=strlen(tel[i]);
    k=0;
    for (j=0;j<l;j++)
    {
    switch (tel[i][j])
    {
    case 'A': decode[i][k++]='2'; break;
    case 'B': decode[i][k++]='2'; break;
    case 'C': decode[i][k++]='2'; break;
    case 'D': decode[i][k++]='3'; break;
    case 'E': decode[i][k++]='3'; break;
    case 'F': decode[i][k++]='3'; break;
    case 'G': decode[i][k++]='4'; break;
    case 'H': decode[i][k++]='4'; break;
    case 'I': decode[i][k++]='4'; break;
    case 'J': decode[i][k++]='5'; break;
    case 'K': decode[i][k++]='5'; break;
    case 'L': decode[i][k++]='5'; break;
    case 'M': decode[i][k++]='6'; break;
    case 'N': decode[i][k++]='6'; break;
    case 'O': decode[i][k++]='6'; break;
    case 'P': decode[i][k++]='7'; break;
    case 'Q': break;
    case 'R': decode[i][k++]='7'; break;
    case 'S': decode[i][k++]='7'; break;
    case 'T': decode[i][k++]='8'; break;
    case 'U': decode[i][k++]='8'; break;
    case 'V': decode[i][k++]='8'; break;
    case 'W': decode[i][k++]='9'; break;
    case 'X': decode[i][k++]='9'; break;
    case 'Y': decode[i][k++]='9'; break;
    case 'Z': break;
    case '-': break;
    default: decode[i][k++]=tel[i][j];
    }
    }
    decode[i][k]='\0';
    }

    qsort(decode,n,sizeof(decode[0]),cmp);

    i=0;
    k=1;
    strcpy(now,decode[i]);
    flag = 0;
    while (i<n-1)
    {
    if (strcmp(decode[i+1],now) == 0)
    {
    k++;
    }
    else if (k>1)
    {
    for (j=0;j<3;j++) printf("%c",now[j]);
    printf("-");
    for (j=3;j<7;j++) printf("%c",now[j]);
    printf(" %d\n",k);
    strcpy(now,decode[i+1]);
    k=1;
    flag=1;
    }
    else
    {
    k=1;
    strcpy(now,decode[i+1]);
    }
    i++;
    }
    if (flag == 0)
    {
    printf("No duplicates.\n");
    }
    return 0;
    }

  • lmz
    lmz 18.1.29 回复

    兄弟你有测试点吗?
    来几个

想要评论吗?

注册OpenJudge账号,如果您已经注册,请先登入