您的位置:首页 > 其它

HDU 1073 Online Judge

2012-10-09 15:13 381 查看


Online Judge

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 3338 Accepted Submission(s): 1253



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


Author

Ignatius.L

分析:本题我们可以把我们的输入和正确的答案存成2个字符串一一对照,得出结果,但是注意像第2个测试数据我们有2行输入,第二行空相当于一个'\0',

所以我们要写个循环把每一行的值都存入相同一个串,再比较

代码:

#include<stdio.h>
#include<string.h>

char a[5010];
char b[5010];
char c[5010];

int main()
{
int T;
scanf("%d",&T);
getchar();
while(T--)
{
int len1=0,len2=0,i,j,k,flag=0;
memset(a,'0',sizeof(a));
memset(b,'0',sizeof(b));
gets(c);
while(gets(c)&&strcmp(c,"END")!=0)
{
k=strlen(c);
for(i=0;i<=k;i++)
{
a[len1]=c[i];
len1++;
}
}
gets(c);
while(gets(c)&&strcmp(c,"END")!=0)
{
k=strlen(c);
for(i=0;i<=k;i++)
{
b[len2]=c[i];
len2++;
}
}
for(i=0,j=0;i<=len1&&j<=len2;)
{
if(a[i]!=b[j])
{
if(a[i]==' '||a[i]=='\t'||a[i]=='\0')
{
i++;
flag=1;
}
else if(b[j]==' '||b[j]=='\t'||b[j]=='\0')
{
j++;
flag=1;
}
else
{
flag=2;
break;
}
}
else
{
i++;
j++;
}
}
if(flag==0)
printf("Accepted\n");
else if(flag==1)
printf("Presentation Error\n");
else if(flag==2)
printf("Wrong Answer\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: