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

就是输入输出,简单的判断PE,WA,AC这几种情况。

START是开始输入了,

END是结束输入了。数据在这个之间!

每一组有2个 START和END。

就是判断这2个之间的数据是PE,WA还是AC。

分析:

用2字符串分别存储这2个需要比较的数据,遇到换行需要在字符串中加入’\n’。

先看这2个字符串是不是相等,如果相等,就是AC。

不相等,再来判断是PE还是WA。

import java.util.Scanner;
/**
* @author 陈浩翔
*
* 2016-5-26
*/
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while (t-- > 0) {
String a = "";
String b = "";
while (true) {
String str = sc.nextLine();
if ("END".equals(str)) {
break;
}
if ("START".equals(str)) {
continue;
}
a=a+str;
a=a+"\n";
} while (true) {
String str = sc.nextLine();
if ("END".equals(str)) {
break;
}
if ("START".equals(str)) {
continue;
}
b=b+str;
b=b+"\n";
}
int con = 0;// -1--PE,0--WA,1--AC // System.out.println(a);
// System.out.println(a.length());
// System.out.println(b);
// System.out.println(b.length()); if(a.equals(b)){
con=1;
}else{
con=-1;
String stra="";
for(int i=0;i<a.length();i++){
if(a.charAt(i)==' '||a.charAt(i)=='\t'||a.charAt(i)=='\n'){
continue;
}
stra=stra+a.charAt(i);
}
String strb="";
for(int i=0;i<b.length();i++){
if(b.charAt(i)==' '||b.charAt(i)=='\t'||b.charAt(i)=='\n'){
continue;
}
strb=strb+b.charAt(i);
}
// System.out.println(stra);
// System.out.println("-------------");
// System.out.println(strb);
if(stra.equals(strb)){
con=-1;
}else{
con=0;
}
} if(con==0){
System.out.println("Wrong Answer");
}else if(con==-1){
System.out.println("Presentation Error");
}else{
System.out.println("Accepted");
}
}
}
}

最新文章

  1. spring batch资料收集
  2. java 反序列化PHP
  3. sprint 1 总结
  4. 无法debug断点跟踪JDK源代码——missing line number attributes的解决方法
  5. Linux编译安装Darwin Streaming Server 6.0.3
  6. Visual Studio Gallery
  7. 五个免费UML建模工具推荐
  8. JavaScript 高级程序设计 目录
  9. jsoncpp使用
  10. 认识 Java Message Service
  11. PhiloGL学习(2)——骚年,让我们荡起双桨
  12. [模拟]P1202 [USACO1.1]黑色星期五Friday the Thirteenth
  13. 原生js代码挑战之动态添加双色球
  14. 前端面试题整理—JavaScript篇(二)
  15. Xilinx Vivado的使用详细介绍(5):调用用户自定义封装的IP核
  16. PHP实用代码片段(二)
  17. Confluence 6 安装 Oracle
  18. javascript 高级程序设计 八
  19. LIS问题(DP解法)---poj1631
  20. HDUOJ------------1051Wooden Sticks

热门文章

  1. 从腾讯QQ升级游戏之&ldquo;快速加入游戏&rdquo;功能的实现缺陷看C/S之间如何正确分配相关协作
  2. 收集SQLServer线程等待信息
  3. oracle rowid 使用
  4. Oracle: Oracle行转列、列转行的Sql语句总结
  5. Objective c 自动释放池
  6. 学会怎样使用Jsp 内置标签、jstl标签库及自定义标签
  7. list集合练习一
  8. windows进程函数试炼
  9. js中的prototye
  10. Oracle中Long类型的使用与不可使用