HDU 1073 Online Judge
2013-04-18 15:25
309 查看
Online Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3878 Accepted Submission(s): 1452
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 错了2次,第一次没有处理好空行这种情况,第二次在去掉空格 时,同时存在两个空格这个情况没有处理好。 #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { /*freopen("in.txt","r",stdin);*/ int i,j,cas,flag1; char line[300],a[5010],b[5010]; scanf("%d\n",&cas); while(cas--) { scanf("START\n"); a[0]='\0'; b[0]='\0'; while(1) { fgets(line,300,stdin); flag1=strlen(line); line[flag1-1]='\0'; if(strcmp(line,"END")==0) { a[strlen(a)]='\0'; break; } if(line[0]=='\0') { line[0]='\n'; line[1]='\0'; } strcat(a,line); } scanf("START\n"); while(1) { fgets(line,300,stdin); flag1=strlen(line); line[flag1-1]='\0'; if(strcmp(line,"END")==0) { b[strlen(b)]='\0'; break; } if(line[0]=='\0') { line[0]='\n'; line[1]='\0'; } strcat(b,line); } flag1=0; j=0; if(strcmp(a,b)==0) { printf("Accepted\n"); continue; } for(i=0; a[i]!='\0'; i++) { if(a[i]==' '||a[i]=='\n'||a[i]=='\t') { for(j=i; a[j]!='\0'; j++) a[j]=a[j+1]; i--; } } for(i=0; b[i]!='\0'; i++) { if(b[i]==' '||b[i]=='\n'||b[i]=='\t') { for(j=i; b[j]!='\0'; j++) b[j]=b[j+1]; i--; } } if(strcmp(a,b)==0) { printf("Presentation Error\n"); continue; } else { printf("Wrong Answer\n"); continue; } } return 0; }
相关文章推荐
- HDU 1073 Online Judge(字符串输入方面的经验)
- hdu 1073 Online Judge
- HDU 1073 Online Judge
- HDU 1073 Online Judge
- HDU 1073 Online Judge
- hdu 1073 Online Judge
- HDU 1073 Online Judge (字符串处理,简单题)
- HDU 1073- Online Judge
- HDU--1073:Online Judge (字符串)
- HDU1073 Online Judge
- hdu 1073 Online Judge
- HDU——1073Online Judge(string类以及其对应函数)
- hdu 1073 Online Judge
- HDU 1073 Online Judge
- HDU_1073Online Judge
- hdu 1073 Online Judge
- hdu 1073 Online Judge(4)
- HDU 1073 Online Judge (字符串处理,格式判断的好题!!!!)
- HDU 1073 Online Judge(字符串)
- HDU 1073:Online Judge