ACM--OJ判题--HDOJ 1073--Online Judge--字符串
2016-07-18 13:51
405 查看
HDOJ题目地址:传送门
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6939 Accepted Submission(s): 2655
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
Online Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6939 Accepted Submission(s): 2655
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
#include <cstdlib> #include <string> #include <iostream> #include <sstream> #include <cctype> using namespace std; string src, dest, start, end; char sa[5001], sb[5001]; void readContent(string &s){ s.clear(); string ts; while (getline(cin, ts)){ if (ts != "END"){ s += ts; s += "\n"; } else{ break; } } } void judge(const string &src, const string &dest, bool &af, bool &pf, bool &wf){ af = pf = wf = false; if (src == dest){ af = true; return; } pf = true; int pos = 0; for (int i = 0; i < src.length(); ++i){ if (!isspace(src[i])){ sa[pos++] = src[i]; } } sa[pos] = 0; pos = 0; for (int i = 0; i < dest.length(); ++i){ if (!isspace(dest[i])){ sb[pos++] = dest[i]; } } sb[pos] = 0; string sa_s,sb_s; sa_s=sa;sb_s=sb; if(sa_s.compare(sb_s)!=0){ wf = true; } } int main(){ int t; bool af, pf, wf; cin >> t; while (t--){ cin >> start; readContent(src); cin >> start; readContent(dest); judge(src, dest, af, pf, wf); if (af){ cout << "Accepted" << endl; } else if (wf){ cout << "Wrong Answer" << endl; } else{ cout << "Presentation Error" << endl; } } return 0; }
相关文章推荐
- Android Studio工程导入另一个工程作为lib
- 一个页面如何放多个百度编辑器 Ueditor 1.4.3?PHP如何获取Ueditor 的值?
- 五年26个版本:Linux系统内核全程回顾
- POJ - 3321 Apple Tree
- Open Asset Import Library详解
- 字符
- Linux下查看内核、CPU、内存及各组件版本的命令和方法
- 图片轮播
- Hdu3812-Sea Sky(深搜+剪枝)
- web04-LoginServlet
- Android ListView/GridView 中Adapter的用法(1)
- git之:分支管理策略
- Python中的cls与self的区别
- Sublime text 3编辑器快捷键说明
- WebView使用(2)下载文件
- 排序——堆排序
- butterknife 8.2.1简单使用
- 2016年团体程序设计天梯赛-决赛 L2-1 红色警报
- IT-ELk-安装
- C/C++的开发环境安装