Online Judge(字符串-格式)
Online Judge
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
Sample Output
Presentation Error
Presentation Error
Wrong Answer
Presentation Error
// 挺好的题,想了一阵,没想到好的方法,看了kuangbin大神的思路,很强, 把'\n'当字符加进去,再把实际数据分理出来,比较,是个很好的方法
还是太菜啊,继续刷题!!!
#include <bits/stdc++.h>
using namespace std;
#define MX 5005 char s1[MX],s2[MX];
char data1[MX],data2[MX];
char tmp[MX]; void input(char *a,char *b)
{
gets(tmp);
while (gets(tmp))
{
if (strcmp(tmp,"END")==) break;
strcat(a,tmp);
strcat(a,"\n");
}
int t=;
int len = strlen(a);
for (int i=;i<len;i++)
{
if (a[i]!=' '&&a[i]!='\t'&&a[i]!='\n')
b[t++]=a[i];
}
b[t++]='\0';
} int main()
{
int T;
cin>>T;
getchar();
while (T--)
{
s1[]='\0';
s2[]='\0';
input(s1,data1);
input(s2,data2);
if (strcmp(s1,s2)==)
printf("Accepted\n");
else if (strcmp(data1,data2)==)
printf("Presentation Error\n");
else
printf("Wrong Answer\n");
}
return ;
}
Online Judge(字符串-格式)的更多相关文章
- vb.net字符串格式转为日期型
vb.net字符串格式转为日期型 比如 "20080815" 转换为"2008-05-15"Dim a As Date Dim s As String = ...
- string.Format出现异常"输入的字符串格式有误"的解决方法
string.Format出现异常"输入的字符串格式有误"的解决方法 今天在做项目时,碰到一个很奇怪的问题,我使用string.Format居然报“输入的字符串格式有误”的错误,我 ...
- javascript中字符串格式json如何转化成json对象
什么是JSON JSON(JavaScript Object Notation)是一种优美的JavaScript对象创建方法.JSON也是一种轻量级数据交换格式.JSON非常易于人阅读与编写,同时利于 ...
- Java将其他数据格式转换成json字符串格式
package com.wangbo.util; import java.beans.IntrospectionException; import java.beans.Introspector; i ...
- javascript中字符串格式转化成json对象记录
什么是JSON JSON(JavaScript Object Notation)是一种优美的JavaScript对象创建方法.JSON也是一种轻量级数据交换格式.JSON非常易于人阅读与编写,同时利于 ...
- 把json格式对象转成可提交字符串格式,会过滤掉函数 {a: {b: 3}, b: [1], c: "d"} -> a.b=3&b[0]=1&c=d
var json = { name: "任务名称" , scoreRule: "", score: "", // 如果规则表达式不为空,则默 ...
- EasyUI datagrid 分页Json字符串格式
//EasyUI datagrid 分页Json字符串格式 //{"total":xx,"rows":[{...},{...}]} total:总数 rows: ...
- string.Format字符串格式说明
先举几个简单的应用案例: 1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元) string.Format("{0:C}",0.2) 结果为:¥0.20 ...
- 转换字符串格式,可用于sql in
/// <summary> /// 转换字符串格式,可用于sql in /// </summary> /// <param name="lst"> ...
随机推荐
- HDFS主要节点解说(一)节点功能
1 HDFS体系结构简单介绍及优缺点 1.1体系结构简单介绍 HDFS是一个主/从(Mater/Slave)体系结构.从终于用户的角度来看,它就像传统的文件系统一样,能够通过文件夹路径对文件运行CR ...
- 微信小程序 - 更改button状态
wxml <button class='yes-orders' style='{{status_css}}' bindtap='clickExpress'> {{statusOrders} ...
- linux下confstr与uname函数_获取C库与内核信息
#include <stdio.h> #include <sys/utsname.h> //uname int main(int argc, char **argv[]) { ...
- 每日一个机器学习算法——k近邻分类
K近邻很简单. 简而言之,对于未知类的样本,按照某种计算距离找出它在训练集中的k个最近邻,如果k个近邻中多数样本属于哪个类别,就将它判决为那一个类别. 由于采用k投票机制,所以能够减小噪声的影响. 由 ...
- mybatis+oracle的批量插入
// 批量插入,手动控制事务 SqlSession batchSqlSession = null; try { batchSqlSession = sqlSessionTemplate.getSqlS ...
- 保存Hive查询结果的方法
很多时候,我们需要将Hive的查询(select)结果保存起来,方便进一步处理或查看.在Hive里面提供了不同的方式来保存查询结果,在这里做下总结: 一.保存结果到本地 方法1:调用hive标准输出, ...
- iOS 提示更新 业务逻辑
1, 当程序启动,先去APPstore 检查有没有新版本.没有新版本就不提示,有新版本才提示. 2,只有当有提示了,再去判断是强制更新还是普通提示. 3,当后台给返回要强制更新时,就给出提示,并且没有 ...
- Xilinx_7_Series_GTX简介
Xilinx_7_Series_GTX简介 https://wenku.baidu.com/view/4639cde7bb68a98270fefab6.html
- Camera2/HAL3
Android Camera HAL3中拍照Capture模式下多模块间的交互与帧Result与帧数据回调https://blog.csdn.net/gzzaigcnforever/article/d ...
- 设计模式之迪米特原则(LoD)
迪米特原则也叫作最少知识原则,也就是:一个对象应该对其他对象有最少的了解.也就是说一个对象应该尽量的保证高内聚性,不应该对外有太多的public方法.