题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073

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

伊格内修斯正在建立一个在线法官,现在他已经研究出除法官系统以外的所有问题。系统必须从正确的输出文件和用户的结果文件读取数据,然后系统比较这两个文件。如果两个文件绝对相同,则判定系统返回“Accepted”,否则如果两个文件之间的唯一区别是空格('  '),制表符('\t')或输入('\n'),法官系统应返回“Presentation Error”,否则系统将返回“Wrong Answer”。

给定正确输出文件的数据和用户结果文件的数据,您的任务是确定判定系统将返回哪个结果。

输入

输入包含多个测试用例。输入的第一行是单个整数T,它是测试用例的数量。 T测试用例如下。 每个测试用例都有两个部分,正确输出文件的数据和用户结果文件的数据。它们都是以单行开始,包含一个字符串“START”,并以单行结尾包含一个字符串“END”,这两个字符串不是数据。换句话说,数据在两个字符串之间。数据最多为5000个字符。

输出

对于每个测试用例,您应输出Judge System应返回的结果。

解题思路:

做这道题时,因为我们只知道数据是在START与END之间给出的,而且从输入输出实例来看,我们需要循环读入START与END之间的每行字符串,保存在一个字符数组中,再循环读入非空格,制表符,换行符的字符到另一个字符数组中,这样来比较,思路就很清楚了,注解在代码中。。。

AC代码:

 #include<bits/stdc++.h>
using namespace std;
const int N=;
char tmp[N];//用来读取暂时的字符串
char a1[N],a2[N],b1[N],b2[N];
void input(char *a,char *b)
{
gets(tmp);//首先读入START
while(strcmp(tmp,"START")!=)gets(tmp);//当输入的不是START(有可能是空行)时,继续输入,否则就不执行此句
while(gets(tmp)){//接下来循环读入START与END之间的每行字符串
if(strcmp(tmp,"END")==)break;//结束条件,跳出
if(strlen(tmp)!=)strcat(a,tmp);//当输入的不是空字符串的时候(忽略单行的空字符串),即可链接保存在a数组后面
strcat(a,"\n");//多加一个换行符,下次链接的时候就可直接把'\n'覆盖掉,保留实际的行读入操作,同时也作为标记
}
int k=,n=strlen(a);
for(int i=;i<n;++i)//循环赋值给b数组
if(a[i]!=' ' && a[i]!='\t' && a[i]!='\n')b[k++]=a[i];//当a是空格,制表符,结束符则不保存在b数组里面
b[k]='\0';//要求匹配对应的格式
}
int main()
{
int t;
cin>>t;
while(t--){
a1[]=a2[]=b1[]=b2[]='\0';//记得数组初始化
input(a1,b1);//两部分输入
input(a2,b2);
if(strcmp(a1,a2)==)cout<<"Accepted"<<endl;//当a1==a2时表明文本输入相同
else if(strcmp(b1,b2)==)cout<<"Presentation Error"<<endl;//否则修改后表明格式不匹配
else cout<<"Wrong Answer"<<endl;//否则就是错误答案
}
return ;
}

解题报告:hdu 1073 Online Judge的更多相关文章

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

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

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

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

  3. HDU 1073 Online Judge(字符串)

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

  4. HDU 1073 - Online Judge

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

  5. 杭州电子科技大学Online Judge 之 “确定比赛名次(ID1285)”解题报告

    杭州电子科技大学Online Judge 之 "确定比赛名次(ID1285)"解题报告 巧若拙(欢迎转载,但请注明出处:http://blog.csdn.net/qiaoruozh ...

  6. HDU 4303 Hourai Jeweled 解题报告

    HDU 4303 Hourai Jeweled 解题报告 评测地址: http://acm.hdu.edu.cn/showproblem.php?pid=4303 评测地址: https://xoj. ...

  7. 【解题报告】 Leapin' Lizards HDU 2732 网络流

    [解题报告] Leapin' Lizards HDU 2732 网络流 题外话 在正式讲这个题目之前我想先说几件事 1. 如果大家要做网络流的题目,我在网上看到一个家伙,他那里列出了一堆网络流的题目, ...

  8. 【九度OJ】题目1073:杨辉三角形 解题报告

    [九度OJ]题目1073:杨辉三角形 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1073 题目描述: 输入n值,使用递归函数,求杨 ...

  9. HDU 4869 Turn the pokers (2014多校联合训练第一场1009) 解题报告(维护区间 + 组合数)

    Turn the pokers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

随机推荐

  1. 信号量学习 & 共享内存同步

    刚刚这篇文章学习了共享内存:http://www.cnblogs.com/charlesblc/p/6142139.html 里面也提到了共享内存,自己不进行同步,需要其他手段比如信号量来进行.那么现 ...

  2. 安装软件:/lib/ld-linux.so.2: bad ELF interpreter解决

    http://linux.chinaitlab.com/set/928509.html 我们在CentOS系统中安装软件:/lib/ld-linux.so.2: bad ELF interpreter ...

  3. Cubieboard搭建Hadoop指南

    1.刷固件 出厂的Cubieboard是Android系统,需要Linux系统安装Hadoop,到此网址下载: http://dl.cubieboard.org/software/a20-cubiet ...

  4. react 组件之间传值

    谈及React时,就会想到一个很重要的思想,就是组件化思想.它将可以重用的部分进行组件化开发,形成一个个相对独立的组件,那么组件化后,你也会提出些疑问,组件与组件之间,将怎样进行信息的传递呢?下面来介 ...

  5. springMVC4(16)拦截器解析与登陆拦截模拟

    在SpringMVC中,我们会常常使用到拦截器,尽管SpringAOP也能帮我们实现强大的拦截器功能,但在Web资源供给上.却没有SpringMVC来得方便快捷. 使用SpringMVC拦截器的核心应 ...

  6. Hive中行列转换

    1.演示多列转为单行 数据文件及内容: student.txt xiaoming|english|92.0 xiaoming|chinese|98.0 xiaoming|math|89.5 huahu ...

  7. LoaderManager使用具体解释(四)---实例:AppListLoader

    实例:AppListLoader 这篇文章将是我的第四篇,也就是最后一篇该系列的文章.请在评论里面告诉我他们是否实用.前面几篇文章的链接例如以下: 一:Loaders之前世界 二:了解LoaderMa ...

  8. OpenCV入门笔记(二) 图片的文件操作

    以下介绍一下重要的几个,设计基本 图片处理 的函数,依次来了解OpenCV的入门知识.具体的具体使用方法还是以官方的API[Official Tutorials][Python-OpenCV]为准. ...

  9. BZOJ1087=Codevs2451=洛谷P1896&P2326互不侵犯

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2885  Solved: 1693[Submit][ ...

  10. ELF和a.out文件格式的比较

    本文讨论了 UNIX/LINUX 平台下三种主要的可执行文件格式:a.out(assembler and link editor output 汇编器和链接编辑器的输出).COFF(Common Ob ...