hdu 1073 Online Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5071 Accepted Submission(s): 1925
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
/*题解:
依然是靠写外部函数解决,多写函数使思路明晰。
一个input()输入数据,一个cmp()比较去掉' ','\n','\t'之后的数据
*/
#include<cstdio>
#include<cstring>
char str1[5050],str2[5050]; //注意题目中的数组长度
int input(char a[5050],char b[5050]){
while(gets(a)&&strcmp(a,"END")){
if(strlen(a)==0)
strcat(str1,"\n");
else
strcat(str1,a);
}
while(gets(b)&&strcmp(b,"END")){
if(strlen(b)==0)
strcat(str2,"\n");
else
strcat(str2,b);
}
}
int cmp(char a[5050],char b[5050]){
char s1[5050],s2[5050];
int len1=strlen(a),len2=strlen(b),i,j;
if(strcmp(a,b)==0) printf("Accepted\n");
else{
for(i=0,j=0; i<len1; i++)
if(a[i]!=' '&&a[i]!='\t'&&a[i]!='\n')
s1[j++]=a[i];
s1[j]='\0';
for(i=0,j=0; i<len2; i++)
if(b[i]!=' '&&b[i]!='\t'&&b[i]!='\n')
s2[j++]=b[i];
s2[j]='\0';
if(strcmp(s1,s2)==0)
printf("Presentation Error\n");
else
printf("Wrong Answer\n");
}
}
int main(){
int n;
char a[5050],b[5050];
scanf("%d",&n);
getchar();
while(n--){
memset(str1,0,sizeof(str1));
memset(str2,0,sizeof(str2));//这里必须初始化
// memset(a,0,sizeof(a));//这里可以不初始化
// memset(b,0,sizeof(b));
input(a,b);
cmp(str1,str2);
}
return 0;
}
hdu 1073 Online Judge
原创
©著作权归作者所有:来自51CTO博客作者wx5f8d5a7b525f9的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:As Easy As A+B
下一篇:hdu题目分类
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
浅谈online judge平台 spj [special judge] 使用 | 修改问题
浅谈oj平台
c++ online judge #include ios 文件指针 -
Online Judge System 中术语含义
大家在刷题时,常见的 OJ 平台(例如:洛谷)都会遇到测试点提示的信息
OJ ACM LeetCode 测试点 提示信息 -
鲁东大学LDU Online Judge图片展示
登录,部分内容是普通用户看不到的。前台用户端首页提交记录/状态题库课程/实验Training(专题训练)、Contests(竞赛)、Ended(已结束课程/专题/竞赛汇总)同上刷题榜(日/周/月/年)后台管理系统概览/判题机用户管理...
onlinejudge lduoj 程序设计竞赛 github 权限管理