# 題目: UVa 10188 - Automated Judge Script
# 題目說明
程式競賽的評審很嚴格但又很懶散,他們希望能少一點工作及多一點錯誤答案
你需要寫一個自動化的評審系統,根據標準答案及回答,給出:
Accepted、Presentation Error、Wrong Answer其中之一
Accepted:string中所有字元皆相同Presentation Error: 所有數字皆正確,但至少有1個以上的字元錯誤Wrong Answer: 數字錯誤
INPUT:
每筆資料第一行有一個整數N,代表接下來有幾行標準答案
接下來輸入N個string
當N = 0時結束程式
之後會有一個整數M,代表接下來有幾行回答
接下來輸入M個string
OUTPUT:
每筆資料輸出一個Accepted、Presentation Error或Wrong Answer
# 解題方法
先用兩個vector儲存資料
比對兩個vector是否完全相同,相同則輸出Accepted
接著將兩個vector中的所有數字分別存入兩個string
若兩個string相同則輸出Presentation Error
否則則輸出Wrong Answer
# 參考程式碼
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int N, M, cases = 0;
string tmp;
while (cin >> N, N)
{
vector<string> ans, team;
cin.ignore();
while (N--)
{
getline(cin, tmp);
ans.emplace_back(tmp);
}
cin >> M;
cin.ignore();
while (M--)
{
getline(cin, tmp);
team.emplace_back(tmp);
}
cout << "Run #" << ++cases << ": ";
if (ans == team)
{
cout << "Accepted\n";
continue;
}
string ans_num, team_num;
for (auto& i : ans) for (auto& j : i)
{
if (j >= '0' && j <= '9') ans_num.push_back(j);
}
for (auto& i : team) for (auto& j : i)
{
if (j >= '0' && j <= '9') team_num.push_back(j);
}
if (ans_num == team_num) cout << "Presentation Error\n";
else cout << "Wrong Answer\n";
}
return 0;
}