PC/UVa:110305/10188
题目很简单,照着模拟就好了,这才发现自动评测系统这么弱智的。
可是我自己写字符串比较函数居然写错了,事实证明在for
循环中初始化循环变量可以避免很多错误。
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string getDigit(const vector<string> &vecstrInput)
{
string strRet;
for (size_t i = 0; i < vecstrInput.size(); i++)
{
for (size_t j = 0; j < vecstrInput[i].size(); j++)
{
if (isdigit(vecstrInput[i][j])) strRet.push_back(vecstrInput[i][j]);
}
}
return strRet;
}
void judge(const vector<string> &vecstrAnswer, const vector<string> &vecstrCommit)
{
//首先判断是否AC
if (vecstrAnswer.size() == vecstrCommit.size()){
bool bAC = true;
for (size_t i = 0; i < vecstrAnswer.size(); i++)
{
if (vecstrAnswer[i] != vecstrCommit[i]){
bAC = false;
break;
}
}
if (bAC){
cout << "Accepted" << endl;
return;
}
}
//不AC的情况在判断是否PE
string strAnswer, strCommit;
strAnswer = getDigit(vecstrAnswer);
strCommit = getDigit(vecstrCommit);
if (strAnswer == strCommit){
cout << "Presentation Error" << endl;
return;
}
//否则就是WA
cout << "Wrong Answer" << endl;
return;
}
int main()
{
int n = 0, m = 0, cnt = 1;
while (cin >> n){
if (n == 0) break;
cin.get();
vector<string> vecstrAnswer, vecstrCommit;
string strAnswer, strCommit;
for (int i = 0; i < n; i++)
{
getline(cin, strAnswer);
vecstrAnswer.push_back(strAnswer);
}
cin >> m;
cin.get();
for (int i = 0; i < m; i++)
{
getline(cin, strCommit);
vecstrCommit.push_back(strCommit);
}
cout << "Run #" << cnt++ << ": ";
judge(vecstrAnswer, vecstrCommit);
}
return 0;
}
/*
2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 15
2
The answer is: 10
The answer is: 5
2
The answer is: 10
The answer is: 5
3
Input Set #1: YES
Input Set #2: NO
Input Set #3: NO
3
Input Set #0: YES
Input Set #1: NO
Input Set #2: NO
1
1 0 1 0
1
1010
1
The judges are mean!
1
The judges are good!
0
*/