题目链接: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. BC一周年B

    #include <cstdio> #include <iostream> #include <algorithm> #include <queue> ...

  2. linux之rsync远程数据同步备份

    rsync服务是一种高效的远程数据备份的工具,该服务的port号为873, 是Liunx下的一种非独立服务.由xinetd超级服务管理,取代监听873port. 长处: 1.rsync能够利用ssh和 ...

  3. 简单了解eMMC

    以下只是个人看法,有不妥之处,请批评指出. 参考资料:http://www.veryarm.com/1200.html 一.eMMC的发展 ROM→NorFlash→NandFlash→eMMC→UF ...

  4. React通过Ajax获取数据

    React 组件的数据可以通过 componentDidMount 方法中的 Ajax 来获取,当从服务端获取数据库可以将数据存储在 state 中,再用 this.setState 方法重新渲染 U ...

  5. 嵌入式开发之davinci---dm8168VPORT口管脚总结

    http://blog.csdn.net/shanghaiqianlun/article/details/7531365

  6. 32位与4G内存限制

    32位有4G内存限制,好像人所共知.但这个32位是指32位的CPU还是32位的操作系统? 答案是,都是.内存限制,是操作系统和硬件(CPU,也许还有内存控制器)共同制约的.CPU对应的是寻址物理地址, ...

  7. MySQL服务无法启动(1067)问题

    关于这个问题网上的帖子和说法多如牛毛,是在难以分辨真假,或者是否与自己的出错情况相同. 有了前车之鉴,就有必要提前声明,这篇是我在计算机--管理--服务中启动mysql服务时出现的错误,如下: 最后的 ...

  8. 深入理解Java执行时数据区

    前情回想 在本专栏的前12篇博客中. 我们主要大致介绍了什么是JVM, 而且具体介绍了class文件的格式. 对于深入理解Java, 或者深入理解运行于JVM上的其它语言, 深入理解class文件格式 ...

  9. mysql--DML--视图,索引,事务,字符集,函数

    Mysql中,表/列可以改名,database不能改名. phpMyAdmin似乎有这功能? 他是建新库,把所有表复制到新库,再删旧库完成的. 删除一个数据库: drop database 数据库名; ...

  10. YTU 2416: C语言习题 成绩输出

    2416: C语言习题 成绩输出 时间限制: 1 Sec  内存限制: 128 MB 提交: 1111  解决: 417 题目描述 输入n(<=10)个学生的姓名.学号和成绩,将其中不及格者的姓 ...