hdu 1073 Online Judge

翻译 2015年07月07日 11:54:20

题意:对比两个文件,三种输出结果。

1)完全一样,输出"Accepted"(接收);

2)些微差别,输出"Presentation Error"(格式错误);

3)其他,输出"Wrong Answer"(回答错误)。


import java.util.Scanner;

public class p1073 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt() * 2;
//		sc.nextLine();// 接收回车符
		while (t-- > 0) {
			int n = judge();
			if (n == 0) {
				System.out.println("Accepted");
			} else if (n == 1) {
				System.out.println("Presentation Error");
			} else {
				System.out.println("Wrong Answer");
			}
		}
	}

	public static int judge() {
		StringBuffer sb1 = input();
		StringBuffer sb2 = input();
//		System.out.println(sb1.toString() + "---");
//		System.out.println(sb2.toString() + "---");
		int i = 0;
		int j = 0;
		int result = 0;
		while (i < sb1.length()-1) {
			char ch1 = sb1.charAt(i);
			char ch2 = sb2.charAt(j);
			if (ch1 == ' ') {
				while (true) {
					i++;
					ch1 = sb1.charAt(i);
					if (ch1 != ' ') {
						break;
					}
				}
			}
			if (ch2 == ' ') {
				while (true) {
					j++;
					ch2 = sb2.charAt(j);
					if (ch2 != ' ') {
						break;
					}
				}
			}
//			System.out.println("i = " + i + "---.j = " + j);
			if (ch1 != ch2 && ch1 != ' ' && ch2 != ' ') {
				result = 2;//
				break;
			}
			i++;
			j++;
		}
		if (i != j) {
			result = 1;
		}
		return result;
	}

	public static StringBuffer input() {
		Scanner sc = new Scanner(System.in);
		StringBuffer sb = new StringBuffer();// 防止超内存
		while (true) {
			String s = sc.nextLine();
			sb.append(s + " ");// 如果输入的是回车符,那么就只有一个“ ”字符,方便判断空白行
			if (s.equals("END")) {
				break;
			}
		}
//		System.out.println(1);
		return sb;
	}
}


Online Judge

在线评测

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

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", 
如果两个文件完全一样,那么判断系统就返回"Accepted"(接收), 
else if the only differences between the two files are spaces(' '), tabs('\t'), or enters('\n'), the Judge System should return "Presentation Error", 

否则如果有些微的差别,比如空格,字表空格,换行判断系统都会返回"Presentation Error"(格式错误), 

else the system will return "Wrong Answer".
否则系统就会返回 "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.
输入将包含多个测试事件。输入的第一行只用一个整数T,他表示测试事件的个数。紧接着又T个测试事件。
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.
他们两个分别为,起始行包含一个字符串"START",结束行包含一个字符串"END",这两行都没有数据。
In other words, the data is between the two strings. 
其他的单词都是数据。
The data will at most 5000 characters.
 数据最多只有5千个字符。

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

相关文章推荐

HDU 1073 Online Judge

Online JudgeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot...

HDU 1073 Online Judge

Online Judge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T...

hdu 1073 Online Judge(4)

比赛时看大家都把这道题给做了,我就去看了,有思路,但没耐下心去做,现在看了别人的思路,我靠,和我当时想的一样!就想打自己几下。。。。现在又去调了,才发现好多地方以前我还是没注意到,有些是我不理解的,比...

HDU1073 Online Judge

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

HDU 1073 Online Judge

/* 模拟OJ系统进行测评的过程 如何去测评两组数据呢?完全匹配当然就是AC啦,那PE和WA如何发现呢? 题目思路: 将输入的两组数据去掉'\n','\t' 和' ',得到新的两组数据, 那么这两组数...

hdu1073 Online Judge 一道字符串处理的水题,,wa了我一下午。。。这几天发生了点不寻常的事。

Problem Description Ignatius is building an Online Judge, now he has worked out all the problems exc...

HDU1073:Online Judge

Problem Description Ignatius is building an Online Judge, now he has worked out all the problems ex...

hdu 1073 Online Judge

hdu 1073 Online Judge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O...

hdu 字符串水题 hdu1073Online Judge 和 hdu1200To and Fro hdu1321Reverse Text

hdu1073Online Judge #include using namespace std; #define N 256 #define M 5010 char source[...

ACM--OJ判题--HDOJ 1073--Online Judge--字符串

HDOJ题目地址:传送门 Online Judge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)