您的位置:首页 > 其它

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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: