题目链接: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. 【机器学习具体解释】SVM解二分类,多分类,及后验概率输出

    转载请注明出处:http://blog.csdn.net/luoshixian099/article/details/51073885 CSDN−勿在浮沙筑高台 支持向量机(Support Vecto ...

  2. SqlServer 经常使用分页方法总结

    SqlServer 经常使用分页方法总结 以下演示样例总结了,SqlServer数据库 经常使用分页方法,仅供学习參考 A. 使用 RowNumber 和 Between And 组合分页: /*** ...

  3. :>/dev/null 2>&1 的作用

    shell中可能经常能看到:>/dev/null 2>&1 命令的结果可以通过%>的形式来定义输出 /dev/null 代表空设备文件 > 代表重定向到哪里,例如:ec ...

  4. protobuf 一个c++示例

    http://wangjunle23.blog.163.com/blog/static/11783817120126155282640/     1.在.proto文件中定义消息格式 2.使用prot ...

  5. Jenkins系列之-—02 email-ext 邮件模板

    邮件通知配置 系统管理 → 系统设置 → 邮件通知 SMTP 服务器:配置 SMTP 服务器.(不填默认本地运行服务器) 用户默认邮件后缀:注册用户邮件只需填写用户名即可,后缀会加该后缀,如果填写,则 ...

  6. fixedBox固定div漂浮代码 支持ie6以上大部分浏览器

    fixedBox固定div漂浮代码 支持ie6以上大部分浏览器 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E ...

  7. C#数据库连接池 MySql SqlServer

    查阅了一天的资料来学习MySql数据库连接池,终于在一篇博文上找到了,自己也整理了一下,希望对大家有用处 1. 建立连接池 using MySql.Data.MySqlClient; using Sy ...

  8. Unity5.1 新的网络引擎UNET(八) UNET 系统概括

     孙广东   2015.7.12 Server and Host 在Unity 的 网络系统,游戏有 一个server和多个client. 当没有专用的server时,client之中的一个扮演s ...

  9. 2016/2/26 jQuery的技术 1,安装 2,语法选择器$ 事件触发 3,常用jQuery函数

    在<网页制作Dreamweaver(悬浮动态分层导航)>中,运用到了jQuery的技术,轻松实现了菜单的下拉.显示.隐藏的效果,不必再用样式表一点点地修改,省去了很多麻烦,那么jQuery ...

  10. solr入门之多线程操作solr中索引字段的解决

    涉及的问题: 建索引时有一个字段是该词语出现的次数,这个字段是放在solr里的  而我用的是多线程来进行全量导入的,这里就涉及到了多线程问题 多个线程操作同一个变量时怎样处理? 我是这样子做的 : 首 ...