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");
}
}
}
}

HDOJ/HDU 1073 Online Judge(字符串处理~)的更多相关文章

  1. HDU 1073 Online Judge (字符串处理)

    题目链接 Problem Description Ignatius is building an Online Judge, now he has worked out all the problem ...

  2. HDU 1073 Online Judge(字符串)

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

  3. 解题报告:hdu 1073 Online Judge

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073 Problem Description Ignatius is building an Onli ...

  4. HDOJ/HDU 1062 Text Reverse(字符串翻转~)

    Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...

  5. 【HDOJ】1073 Online Judge

    这道题TLE了N多次,完全不明白为什么,稍微改了一下,居然过了.使用gets过的,看讨论帖有人还推荐用hash. #include <stdio.h> #include <strin ...

  6. HDU 1073 - Online Judge

    模拟评测机判断答案 先判断有没有不一样的 有的话再提取出 有效子列 看看有没有错的 #include <iostream> #include <cstdio> #include ...

  7. HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化)

    HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化) 题意分析 给出一系列的石头的数量,然后问石头能否被平分成为价值相等的2份.首先可以确定的是如果石头的价值总和为奇数的话,那 ...

  8. HDOJ(HDU).1258 Sum It Up (DFS)

    HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...

  9. HDOJ(HDU).1035 Robot Motion (DFS)

    HDOJ(HDU).1035 Robot Motion [从零开始DFS(4)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DF ...

随机推荐

  1. 如何在Sql2008中获取表字段属性和注释?

    如何在Sql2008中获取表字段属性和注释? select b.[value] from sys.columns a left join sys.extended_properties b on a. ...

  2. 检测SqlServer服务器IO是否瓶颈

    通过性能监视器监视 Avg. Disk Queue Length   小于2 Avg. Disk sec/Read , Avg. Disk sec/Write  小于10ms 可以用数据收集器定时收集 ...

  3. CSS Positioning(定位)

    Positioning(定位) CSS定位属性允许你为一个元素定位.它也可以将一个元素放在另一个元素后面,并指定一个元素的内容太大时,应该发生什么. 元素可以使用的顶部,底部,左侧和右侧属性定位.然而 ...

  4. 系统设计 - 使用面向 iOS 的本机插件扩展

    本文转自:http://www.cnblogs.com/zhwl/archive/2013/07/26/3217155.html 本文细致探讨了 Xcode(以 iOS 设备为目标)中的 PhoneG ...

  5. QT QString转char*,char*转QString;简单明了,看代码。

    //原始QStringQString qs = QString::fromLocal8Bit("我的");std::string strQs = qs.toStdString(); ...

  6. 【实习记】2014-08-24实习生无法映射磁盘替代方案rsync+非默认端口22设置

    正职开发人员有两个电脑,一个办公网的,一个开发网的.通过samba服务在开发网机器上映射编译环境机的磁盘没有问题. 开发岗实习生使用虚拟机做跳板方式登录编译环境机.上面的方法不能用. 替代方法:rsy ...

  7. php返回相对时间(如:20分钟前,3天前)的方法

    function plural($num) { if ($num != 1) return "s"; } function getRelativeTime($date) { $di ...

  8. 策略模式(Strategy)

    行为型模式:策略模式.模板方法模式.观察者模式.迭代子模式.责任链模式.命令模式.备忘录模式.状态模式.访问者模式.中介者模式.解释器模式 策略模式(Strategy) 策略模式定义了一系列算法,并将 ...

  9. ASP.NET MVC轻教程 Step By Step 13——页面布局

    一般在一个网站中页面会使用相同的结构和元素,如果每个页面都要重复添加这些元素,不仅繁琐更会给我们后期维护带来大麻烦.所以我们采用网页模板之类的技术,将固定不变的元素放入模板,同时留下一些占位符供页面各 ...

  10. NET平台和C#

    .NET平台和C#编程 一.深入.NET框架 1..NET框架具有两个组件:CLR(公共语言运行时)和FCL(框架类库),CLR是.NET框架的基础 2.框架核心类库: System.Collecti ...