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.
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.
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
代码:
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int MAXN=5005;
char a1[MAXN],a2[MAXN];
char b1[MAXN],b2[MAXN];
char temp[MAXN];
void input(char a[],char b[])//正确的输入格式
{
gets(temp);
while(strcmp(temp,"START")!=0)
gets(temp);
while(gets(temp))
{
if(strcmp(temp,"END")==0)
break;
if(strlen(temp)!=0)
strcat(a,temp);//把字符串放在一起处理
strcat(a,"\n");//注意要加换行符,不然就只有一行字符串了
}
int t=0;
int len=strlen(a);
for(int i=0;i<len;i++)// 判断字符是否出现spaces(' '), tabs('\t'), or enters('\n'),去掉。
{
if(!(a[i] == ' ' || a[i] =='\t' || a[i] == '\n'))
b[t++]=a[i];
}
b[t]='\0';//字符串结束符,因为字符串的输入会以‘\0’,为结束符,系统会自动加上,模拟字符串的输入要加上'\0'.
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
a1[0]='\0';
a2[0]='\0';
input(a1,b1);
input(a2,b2);
if(strcmp(a1,a2)==0)//如果输入的第二行字符串,相同就输出"Accepted"
printf("Accepted\n");
else if(strcmp(b1,b2)==0)//如果输入的第二行字符串不同但是第三行字符串,相同就输出"Presentation Error"
printf("Presentation Error\n");
else
printf("Wrong Answer\n");//在上述两个条件都不符合的情况下,输出"Wrong Answer".
}
return 0;
}
解题思路:
输入两个表达式,第一个是正确的,第二个是待鉴定的表达式。
输出 两者之间的关系。(Accepted.Presentation Error.Wrong Answer三种情况之一)