HDOJ1073(Online Judge)(模拟+容器的使用)
2016-01-08 17:28
239 查看
Online Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6453 Accepted Submission(s): 2440
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
getline()函数用于输入流,读取字符到buffer中,直到下列情况发生:
num - 1个字符已经读入,
碰到一个换行标志,
碰到一个EOF,
或者,任意地读入,直到读到字符delim。delim字符不会被放入buffer中。
用容器进行操作简单了许多也比较好理解。
#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<string> v1,v2;
int main()
{
string s,str1,str2;
int test;
cin>>test;
while(test--)
{
while(getline(cin,s))
{
if(s=="START") continue;
if(s=="END") break;
v1.push_back(s);
for(int i=0;i<s.length();i++)
{
if(s[i]!=' '&&s[i]!='\t')
str1+=s[i];
}
}
while(getline(cin,s))
{
if(s=="START") continue;
if(s=="END")
{
if(v1==v2)
printf("Accepted\n");
else if(str1==str2)
printf("Presentation Error\n");
else
printf("Wrong Answer\n");
break;
}
v2.push_back(s);
for(int i=0;i<s.length();i++)
{
if(s[i]!=' '&&s[i]!='\t')
str2+=s[i];
}
}
v1.clear(),v2.clear();
str1.resize(0),str2.resize(0);
}
}
相关文章推荐
- 在老男孩教育的日子里
- Android上传文件到服务器
- php开发中简单的引入编辑器的方法
- Redis学习记录之配置文件(四)
- hive1.2.1源码导入eclipse阅读以及调试
- 自定义View 拓展view 没有全部实现夫view中的构造方法 ApplicationContext is null in ApplicationStatus
- Swift字典
- ios实现长时间后台运行
- Sublime Text Snippets(代码片段)功能
- iOS 6
- Java内存区域及管理
- Linux rpm 命令参数
- 分治算法
- AngularJS学习笔记(二)
- ios--随笔一
- java生成图片
- iOS模拟器键盘输入中文解决方案
- Unity打包内部prefab和读取外部assetbundle的方法详解。
- 关于Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE的报错的最有效的解决方法
- Swift数组