题目链接: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. Mysql不同存储引擎的表转换方法

    Mysql不同存储引擎的表转换方法 1.Alter table直接修改表的存储引擎,但是这样会导致大量的系统开销,Mysql为此要执行一个就表向新表的逐行复制.在此期间,转换操作可能会占用服务器的所有 ...

  2. DRBD原理知识

    DRBD(Distributed Relicated Block Device 分布式复制块设备), 可以解决磁盘单点故障.一般情况下只支持2个节点. 大致工作原理如下图: 一般情况下文件写入磁盘的步 ...

  3. Windows-安装composer

    安装laravel之前必须先安装componser,点击:下载Windows安装程序 全部下一步,直到完成 目前,遇到过两个问题(国内防火墙) 还有就是Win10不支持PHP+Composer的组合, ...

  4. MySql 基本操作语句整理

    数据库 DATABASE: 创建 CREATTE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [DEFAULT] CHARACTER SET [=] cha ...

  5. 设计模式之解释器模式(Interpreter)摘录

    23种GOF设计模式一般分为三大类:创建型模式.结构型模式.行为模式. 创建型模式抽象了实例化过程,它们帮助一个系统独立于怎样创建.组合和表示它的那些对象.一个类创建型模式使用继承改变被实例化的类,而 ...

  6. linux定时访问url

    cd /root touch test.sh #创建文件 vim test.sh #!/bin/sh URL="url地址" curl $URL 保存 退出 #修改文件属性,使其可 ...

  7. 优化 html 标签 为何能用HTML/CSS解决的问题就不要使用JS?

    优化 html 标签 2018年05月11日 08:56:24 阅读数:19 有些人写页面会走向一个极端,几乎页面所有的标签都用div,究其原因,用div有很多好处,一个是div没有默认样式,不会有m ...

  8. mac WebStorm 破解

    摘要:因为想要学习HTML所以需要一个工具,同事推荐了webstorm.下载以后再网上搜破解方法.搜索到一个很简单的. 一.下载链接https://www.jetbrains.com/webstorm ...

  9. 浅谈JavaScript的面向对象程序设计(三)

    前面已经对JavaScript的面向对象程序设计作了简单的介绍,包括了对象的属性.对象的工厂模式.构造函数和原型等.通过介绍,这些创建对象的方法依然有不少优化和改进的地方. 组合使用构造函数模式和原型 ...

  10. 总结文件操作函数(二)-C语言

    格式化读写: #include <stdio.h> int printf(const char *format, ...);                   //相当于fprintf( ...