题目描述

 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.

输入

 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.

输出

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

样例输入
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
样例输出
Presentation Error
Presentation Error
Wrong Answer
Presentation Error

题目链接:http://acm.zznu.edu.cn/problem.php?id=1163

*************************************************

题意:OJ的判题系统,只判 AC , WA ,PE。将所有的字符读入(包括回车)到一个字符串中,逐个比较,如果完全相同 AC , 如果只有space , '\t' 或者 '\n'处不同则 PE 否则 WA

分析:第二行空相当于一个'\0',所以我们要写个循环把每一行的值都存入相同一个串,再比较。

AC代码:

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include<limits.h>
 6 #include <cmath>
 7 #include <cstdlib>
 8 #include <stack>
 9 #include <vector>
10 #include <queue>
11 #include <map>
12 
13 using namespace std;
14 
15 #define N 10000
16 #define INF 0x3f3f3f3f
17 #define met(a, b) memset (a, b, sizeof (a))////  met (dist, -1);
18 #define LL long long
19 
20 char a[N],b[N],s[10],str[N],str1[N];
21 
22 int main()
23 {
24     int T,i,j,len;
25     scanf("%d", &T);
26     getchar();
27 
28     while(T--)
29     {
30         int k=0,l=0,f=0;
31 
32         memset(a,'0',sizeof(a));
33         memset(b,'0',sizeof(b));
34         gets(s);
35         while(gets(str))
36         {
37             if(strcmp(str,"END")==0)
38                 break;
39             len=strlen(str);
40             for(i=0;i<=len;i++)
41                 a[k++]=str[i];
42         }
43 
44         gets(s);
45         while(gets(str1))
46         {
47             if(strcmp(str1,"END")==0)
48                 break;
49 
50             len=strlen(str1);
51             for(i=0;i<=len;i++)
52                 b[l++]=str1[i];
53         }
54 
55         for(i=0,j=0; i<=k&&j<=l;)
56         {
57             if(a[i] != b[j])
58             {
59                 if(a[i] == ' '||a[i] == '\0'||a[i] == '\t')
60                 {
61                     i++;
62                     f=1;
63                 }
64                 else if(b[j]==' '||b[j]=='\0'||b[j]=='\t')
65                 {
66                     j++;
67                     f=1;
68                 }
69                 else
70                 {
71                     f=2;
72                     break;
73                 }
74             }
75             else
76             {
77                 i++;
78                 j++;
79             }
80         }
81 
82         if(f==0)
83             printf("Accepted\n");
84         else if(f==1)
85             printf("Presentation Error\n");
86         else if(f==2)
87             printf("Wrong Answer\n");
88 
89     }
90     return 0;
91 }

 

posted on 2016-08-31 19:26  惟愿。。。  阅读(497)  评论(0编辑  收藏  举报