ZZNU 1163: 在线判题(指针专题)

题目描述

 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 }

 

转载于:https://www.cnblogs.com/weiyuan/p/5827262.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值