您的位置:首页 > 其它

hdu 1073 Online Judge

2015-07-07 11:54 363 查看
题意:对比两个文件,三种输出结果。

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: