Online Judge(字符串-格式)

Posted happy_code

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Online Judge(字符串-格式)相关的知识,希望对你有一定的参考价值。

Online Judge

Problem 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

 

 

// 挺好的题,想了一阵,没想到好的方法,看了kuangbin大神的思路,很强, 把‘\n‘当字符加进去,再把实际数据分理出来,比较,是个很好的方法

还是太菜啊,继续刷题!!!

 

技术分享
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define MX 5005
 4 
 5 char s1[MX],s2[MX];
 6 char data1[MX],data2[MX];
 7 char tmp[MX];
 8 
 9 void input(char *a,char *b)
10 {
11     gets(tmp);
12     while (gets(tmp))
13     {
14         if (strcmp(tmp,"END")==0) break;
15         strcat(a,tmp);
16         strcat(a,"\n");
17     }
18     int t=0;
19     int len = strlen(a);
20     for (int i=0;i<len;i++)
21     {
22         if (a[i]!= &&a[i]!=\t&&a[i]!=\n)
23             b[t++]=a[i];
24     }
25     b[t++]=\0;
26 }
27 
28 int main()
29 {
30     int T;
31     cin>>T;
32     getchar();
33     while (T--)
34     {
35         s1[0]=\0;
36         s2[0]=\0;
37         input(s1,data1);
38         input(s2,data2);
39         if (strcmp(s1,s2)==0)
40             printf("Accepted\n");
41         else if (strcmp(data1,data2)==0)
42             printf("Presentation Error\n");
43         else
44             printf("Wrong Answer\n");
45     }
46     return 0;
47 }
View Code

 

 

 

 

以上是关于Online Judge(字符串-格式)的主要内容,如果未能解决你的问题,请参考以下文章

HDOJ/HDU 1073 Online Judge(字符串处理~)

Online Judge(OJ)搭建——4具体实现

详解OJ(Online Judge)中PHP代码的提交方法及要点

浅谈online judge平台 spj [special judge] 使用 | 修改问题

关于北大OJ(Online Judge)

HDU 1073 - Online Judge