HDOJ 1073 Online Judge
题目
分类
字符处理
题意
写个OJ判题程序
Accepted: 提交和答案完全相同
Presentation Error : 提交和答案只有 空格 ’ ’ 制表符tab ‘\t’ 或 回车 ‘\n’ 不同
Wrong Answer : 不符合以上条件
题解
我的思路
先将两组数据全部读入string(包括所有回车、tab、换行)
如果两组数据完全一致则AC
否则将两组数据的格式字符(包括所有回车、tab、换行)
如果经过上述处理的字符串完全一致则PE,否则AW
代码
#include <iostream>
#include <cstring>
#define maxn 5000
using namespace std;
string a;
string b;
bool isdel(char ch);
bool ispe();
int main()
{
int n;
string s;
cin >> n;
cin.get();
while(n--)
{
a.clear();
b.clear();
while(getline(cin,s) && s != "START");
while(getline(cin,s))
{
if(s == "END")
break;
a += s;
a += '\n';
}
// cout << a <<endl;
while(getline(cin,s) && s != "START");
while(getline(cin,s))
{
if(s == "END")
break;
b += s;
b += '\n';
}
// cout << b << endl;
if(a.length() == b.length() && a == b)
{
cout << "Accepted" << endl;
continue;
}
if(ispe())
cout << "Presentation Error" << endl;
else
cout << "Wrong Answer" << endl;
}
return 0;
}
bool ispe()
{
string aj;
string bj;
for(int i = 0;i < a.length();i++)
if(isdel(a[i]))
aj += a[i];
for(int i = 0;i < b.length();i++)
if(isdel(b[i]))
bj += b[i];
if(aj == bj)
return true;
else return false;
}
bool isdel(char ch)
{
if(ch != ' ' && ch != '\t' && ch != '\n')
return true;
return false;
}