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

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

// 挺好的题,想了一阵,没想到好的方法,看了kuangbin大神的思路,很强, 把‘\n‘当字符加进去,再把实际数据分理出来,比较,是个很好的方法

还是太菜啊,继续刷题!!!

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define MX 5005
 4
 5 char s1[MX],s2[MX];
 6 char data1[MX],data2[MX];
 7 char tmp[MX];
 8
 9 void input(char *a,char *b)
10 {
11     gets(tmp);
12     while (gets(tmp))
13     {
14         if (strcmp(tmp,"END")==0) break;
15         strcat(a,tmp);
16         strcat(a,"\n");
17     }
18     int t=0;
19     int len = strlen(a);
20     for (int i=0;i<len;i++)
21     {
22         if (a[i]!=‘ ‘&&a[i]!=‘\t‘&&a[i]!=‘\n‘)
23             b[t++]=a[i];
24     }
25     b[t++]=‘\0‘;
26 }
27
28 int main()
29 {
30     int T;
31     cin>>T;
32     getchar();
33     while (T--)
34     {
35         s1[0]=‘\0‘;
36         s2[0]=‘\0‘;
37         input(s1,data1);
38         input(s2,data2);
39         if (strcmp(s1,s2)==0)
40             printf("Accepted\n");
41         else if (strcmp(data1,data2)==0)
42             printf("Presentation Error\n");
43         else
44             printf("Wrong Answer\n");
45     }
46     return 0;
47 }

时间: 2024-08-07 08:38:53

Online Judge(字符串-格式)的相关文章

Python程序猿必知的新型字符串格式漏洞

本文对Python开发中引入的一种格式化字符串的新型语法的安全漏洞进行了深入的分析,并提供了相应的安全解决方案. 当我们对不可信的用户输入使用str.format的时候,将会带来安全隐患--对于这个问题,其实我早就知道了,但是直到今天我才真正意识到它的严重性.因为攻击者可以利用它来绕过Jinja2沙盒,这会造成严重的信息泄露问题.同时,我在本文最后部分为str.format提供了一个新的安全版本. 需要提醒的是,这是一个相当严重的安全隐患,这里之所以撰文介绍,是因为大多数人很可能不知道它是多么容

字符串格式

--设置字符串格式 >>> x = 0.123456789 >>> print('value : %.2f' % x) value : 0.12 >>> >>> x = 0.123456789 >>> y = 0.123456789 >>> print('x = %.2f y = %.3f' % (x, y)) x = 0.12 y = 0.123 >>> 其他函数请查字符串函数

string.Format出现异常&quot;输入的字符串格式有误&quot;的解决方法

string.Format出现异常"输入的字符串格式有误"的解决方法 今天在做项目时,碰到一个很奇怪的问题,我使用string.Format居然报“输入的字符串格式有误”的错误,我调了很久,还是不对,不明白错 在哪里,后来还是google了一下,原来我在字符串中出现了"{"字符.而"{"字符若出现在string.Format中是必需转义的,也就是要用两 个"{{"代表一个"{",同时双下面把我查找到的解决方

日期字符串格式化成日期/日期格式化成指定格式字符串

日期字符串格式化成日期 String str="201403060819"; SimpleDateFormat fo = new SimpleDateFormat("yyyyMMddHHmm");//yyyyMMddHHmm是要转化成日期的字符串的格式 Date date = new Date(); try { date = fo.parse(str); } catch (ParseException e) { e.printStackTrace(); } 将上述日

javascript中字符串格式json如何转化成json对象

什么是JSON JSON(JavaScript Object Notation)是一种优美的JavaScript对象创建方法.JSON也是一种轻量级数据交换格式.JSON非常易于人阅读与编写,同时利于机器解析与生成.JSON是在AJAX中代替XML交换数据的更佳方案. JSON格式与语法 var jsonobject={        //对象内的属性语法(属性名与属性值是成对出现的)        propertyname:value, //对象内的函数语法(函数名与函数内容是成对出现的)  

javascript中字符串格式转化成json对象记录

什么是JSON JSON(JavaScript Object Notation)是一种优美的JavaScript对象创建方法.JSON也是一种轻量级数据交换格式.JSON非常易于人阅读与编写,同时利于机器解析与生成.JSON是在AJAX中代替XML交换数据的更佳方案. JSON格式与语法 var jsonobject= {         //对象内的属性语法(属性名与属性值是成对出现的)         propertyname:value, //对象内的函数语法(函数名与函数内容是成对出现的

“System.FormatException”类型的未经处理的异常在 System.IdentityModel.dll 中发生 其他信息: 十六进制字符串格式无效。

如果你的 WebService 客户端证书配置都没问题,唯独调用接口会出现这个错误 "System.FormatException"类型的未经处理的异常在 System.IdentityModel.dll 中发生 其他信息: 十六进制字符串格式无效. 解决办法: 打开你的证书列表,找到证书指纹: 接下来是重点,复制的时候,切记不要用全选,像这样: 要用鼠标仔细的从第一个"可见"字符选起,到"可见"字符结束,像这样: 请仔细对比以上两张图的差别,不

string.Format字符串格式说明

先举几个简单的应用案例: 1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元) string.Format("{0:C}",0.2) 结果为:¥0.20 (英文操作系统结果:$0.20) 默认格式化小数点后面保留两位小数,如果需要保留一位或者更多,可以指定位数 string.Format("{0:C1}",23.15) 结果为:¥23.2 (截取会自动四舍五入) 格式化多个Object实例 string.Format("市场价:

C#将字典转换成name=value这种字符串格式

/// <summary> /// 将字典转换成name=value这种字符串格式 /// </summary> /// <param name="dic"></param> /// <returns></returns> public static string DictionaryToStr(IDictionary<string,string> dic) { //使用排序字典 dic = new S