HDU1073 Online Judge

Online Judge

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6630    Accepted Submission(s): 2506


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
 
题目大意:
就是在线评测系统的程序恩,小伙伴都知道ACM的在线评测吧,也就是OJ系统;他可以评测你的程序给出的答案是对的处理方式(AC)还是错误的处理方式(WA),同样如果答案对了输出是多了空格(" ")或者回车("\n")或者制表符("\t");那么这个程序本身是没有逻辑错误的,但是出谷格式错了,就会给出(PE)的提示;我们要做的就是写这么一个评测程序;

分析:
首先我们得知道,AC就是完全对了,格式正确,答案也正确;
PE 答案对了,格式错误;
WA 答案错了,也就是输出的答案在数据上和正确的答案是不一样的;
值得注意的地方就是对输入字符串的控制;输入的时候如果存在回车("\n");gets是不会吸收掉的,所以我们需要给给次输出后加个特别的字符串(“\t”),这个字符串是可以被吸收的,并且处理数据的时候是可以被发现的;所以它最合适了;
给出AC代码:
#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int main()
{
	char st[10005], ed[10005], te1[10005], te2[10005], x[10005], y[10005];
	int t;
	cin >> t;
	getchar();
	while (t--)
	{
		memset(te1, 0, sizeof(te1));
		memset(te2, 0, sizeof(te2));
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		gets(st);
		while (strcmp(st, "START") != 0)gets(st);
		while (gets(ed))
		{
			if (strcmp(ed, "END") == 0)break;
			strcat(te1, ed);
			strcat(te1, "\t");
		}
		gets(st);
		while (strcmp(st, "START") != 0)gets(st);
		while (gets(ed))
		{
			if (strcmp(ed, "END") == 0)break;
			strcat(te2, ed);
			strcat(te2, "\t");//用来处理回车“\n” 情况下,"\n"不会被te2吸收导致的判断错误;
		}
		int len1 = strlen(te1);
		int len2 = strlen(te2);
		int j;
		for (int i = 0, j = 0; i < len1; i++)
		{
			//cout << te1[i] << ",";
			
			if (te1[i] != ' '&&te1[i]!='\t'&&te1[i]!='\n') 
				x[j] = te1[i], j++;
			
		}
		for (int i = 0, j = 0; i < len2; i++)
		{
			
			if (te2[i] != ' '&&te2[i] != '\t'&&te2[i] != '\n')
				y[j] = te2[i], j++;
		}
		if (strcmp(te1, te2) == 0 && len1 == len2)  //如果两个字符完全一样就AC了;
		{
			cout << "Accepted" << endl;
		}
		else if (strcmp(x, y) == 0)cout << "Presentation Error" << endl; //否则判断其数据部分和运算符部分是不是一样,
																		//一样的话就是PE了;

		else cout << "Wrong Answer" << endl;//如果数据部分或者运算符部分存在不同,那么就是WA了
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值