题目链接
实现(做的比较繁琐,以后再想吧!)
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
struct node {
int score;
int chooseNum;
int correctNum;
int wrongNum;
int options[5];
string answer;
};
int main()
{
int N, M,i,j,score,choose;
char ch;
string str;
cin >> N >> M;
vector<node> ques(M);
for (i = 0; i < M; i++)
{
cin >> ques[i].score >> ques[i].chooseNum >> ques[i].correctNum;
ques[i].answer = "";
ques[i].wrongNum = 0;
for (j = 0; j < 5; j++) ques[i].options[j] = 0;
for (j = 0; j < ques[i].correctNum; j++)
{
cin >> ch;
ques[i].answer += ch;
}
}
getchar();
int wrongNum=0,count=0,m;
double getScore = 0;
string answer;
bool wrong ;
for (i = 0; i < N; i++)
{
getScore = 0; answer = "";
getline(cin, str);
str.erase(remove(str.begin(), str.end(),' '),str.end());
str.erase(remove(str.begin(), str.end(), '('), str.end());
str.erase(remove(str.begin(), str.end(), ')'), str.end());
for (j = 0,count=0; j < str.size();)
{
wrong = false;
answer = str.substr(j+1, str[j]-'0');
if (answer == ques[count].answer)
getScore += ques[count].score;
else
{
ques[count].wrongNum++;
for (m = 0; m < answer.size(); m++)
{
if (ques[count].answer.find(answer[m]) == string::npos)
{
wrong = true;
ques[count].options[answer[m] - 'a'] += 1;
}
}
for (m = 0; m < ques[count].answer.size(); m++)
{
if (answer.find(ques[count].answer[m]) == string::npos)
ques[count].options[ques[count].answer[m] - 'a'] += 1;
}
if (!wrong)
getScore += (ques[count].score*1.0) / 2;
}
j += str[j]-'0'+1;
count++;
}
cout <<fixed<< setprecision(1) << getScore << endl;
}
int maxOfAll=0;
for (i = 0; i < M; i++)
{
int maxOption = *max_element(ques[i].options, ques[i].options+5);
if (maxOption > maxOfAll)
maxOfAll = maxOption;
}
if (maxOfAll == 0)
cout << "Too simple" << endl;
else
{
for (i = 0; i < M; i++)
{
for (j = 0; j < 5; j++)
{
if (ques[i].options[j] == maxOfAll)
cout << maxOfAll << " " << i + 1 << "-" << char(j + 'a') << endl;
}
}
}
return 0;
}