uva10188 - Automated Judge Script

大水题,不过看清题意很重要,

按照题意说的来,,,

代码如下:

#include <cstdio>
#include <cstring>
char a[100][150], b[100][150];
int an[15000], bn[15000];
int n, m;
char ans[3][30] = {"Accepted","Presentation Error","Wrong Answer"};
int ac()
{
    if(n!=m) return 0;
    int tt = 0;
    for(int i = 0; i < n; i++)
        tt+=!(strcmp(a[i],b[i]));
    return tt==n;
}
int pe()
{
    int ak = 0, bk = 0;
    for(int i = 0; i < n; i++)
    {
        int len = strlen(a[i]);
        for(int j = 0; j < len; j++) if(a[i][j]>='0'&&a[i][j]<='9') an[ak++] = a[i][j]-'0';
    }
    for(int i = 0; i < m; i++)
    {
        int len = strlen(b[i]);
        for(int j = 0; j < len; j++) if(b[i][j]>='0'&&b[i][j]<='9') bn[bk++] = b[i][j]-'0';
    }
    if(ak!=bk) return 0;
        for(int j = 0; j < ak; j++) if(an[j]!=bn[j]) return 0;
    return 1;
}
int main ()
{
    int kas, cas = 0;
    while(scanf("%d",&n),n)
    {
        getchar();
        for(int i = 0; i < n; i++) gets(a[i]);
        scanf("%d",&m); getchar();
        for(int i = 0; i < m; i++) gets(b[i]);

        if(ac())      kas = 0;
        else if(pe()) kas = 1;
        else kas = 2;
        printf("Run #%d: %s\n",++cas,ans[kas]);
    }
    return 0;
}


你可能感兴趣的:(uva10188 - Automated Judge Script)