HDU 1073 Online Judge

Online Judge
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit  Status  Practice  HDU 1073

Description

Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user's result file, then the system compare the two files. If the two files are absolutly same, then the Judge System return "Accepted", else if the only differences between the two files are spaces(' '), tabs('\t'), or enters('\n'), the Judge System should return "Presentation Error", else the system will return "Wrong Answer". 

Given the data of correct output file and the data of user's result file, your task is to determine which result the Judge System will return. 
 

Input

The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. 
Each test case has two parts, the data of correct output file and the data of the user's result file. Both of them are starts with a single line contains a string "START" and end with a single line contains a string "END", these two strings are not the data. In other words, the data is between the two strings. The data will at most 5000 characters. 
 

Output

For each test cases, you should output the the result Judge System should return. 
 

Sample Input

 
      
4 START 1 + 2 = 3 END START 1+2=3 END START 1 + 2 = 3 END START 1 + 2 = 3 END START 1 + 2 = 3 END START 1 + 2 = 4 END START 1 + 2 = 3 END START 1 + 2 = 3 END
 

Sample Output

 
      
Presentation Error Presentation Error Wrong Answer Presentation Error

          只能说这是一道让人蛋疼的题,不考算法,就考你的输入输出字符串,没什么好说的,三种情况,AC,WA,PE,PE最难考虑,那就放在最后,直接用strcmp比较相同的就是AC,不同的但是去掉空格 换行也不相同的就是WA,最后PE。

#include
#include
void space(char ans[],char s[])
{
    int i,j=0;
    for(i=0; ans[i]!='\0'; i++)
        if(ans[i]==' '||ans[i]=='\n'||ans[i]=='\t')
            continue;
        else s[j++]=ans[i];
    s[j]='\0';
}
int WA(char ans[],char user[])
{
    char ans_nospace[5050],user_nospace[5050];
    space(ans,ans_nospace);
    space(user,user_nospace);
    if(strcmp(ans_nospace,user_nospace)==0)
        return 0;
    else return 1;
}
int main()
{
    int i,j,n;
    char ans[5010],user[5010],s[5010];
    scanf("%d",&n);
    while(n--)
    {
        while(gets(s))
        {
            if(strcmp(s,"START")==0)
                break;
        }
        i=0;
        while(gets(s))
        {
            if(strcmp(s,"END")==0)
                break;
            for(j=0; s[j]!='\0'; j++)
                ans[i++]=s[j];
            ans[i++]='\n';
        }
        ans[i]='\0';
        while(gets(s))
        {
            if(strcmp(s,"START")==0)
                break;
        }
        i=0;
        while(gets(s))
        {
            if(strcmp(s,"END")==0)
                break;
            for(j=0; s[j]!='\0'; j++)
                user[i++]=s[j];
            user[i++]='\n';
        }

        user[i]='\0';
        if(strcmp(ans,user)==0)
            printf("Accepted\n");
        else if(WA(ans,user)==1)
            printf("Wrong Answer\n");
        else
            printf("Presentation Error\n");
    }
    return 0;
}


你可能感兴趣的:(语言入门)