solution
- 把题目设置为结构体,记录题目的总分,做错该题的人数,题目编号(从1开始),正确答案。对于输入的学生答案提取每道题的回答,与答案对比是否相等,若相等则该同学的分数加上这一题的全分;否则这一题的错题人数加一
- 测试点1:所以题目都没有人做错,输出
Too simple
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct item{int score, cnt = 0, id;string ans = "";friend bool operator < (item &it1, item&it2){return it1.cnt > it2.cnt;}
}items[110];
int main(){int n, m, alls, alln, correct, p, q, get;string t, now;cin >> n >> m;for(int i = 1; i <= m; i++){cin >> items[i].score >> alln >> correct;for(int j = 0; j < correct; j++){cin >> t;items[i].id = i;if(j == 0) items[i].ans += t;else items[i].ans += " " + t;}}getchar(); for(int i = 0; i < n; i++){getline(cin, t);q = get = 0;//q:当前题号,get:当前同学的总分for(int j = 0; j < t.size(); j++){if(t[j] == '('){q++;p = j;while(t[p] != ')') p++;if(t.substr(j + 3, p - j - 3) == items[q].ans) get += items[q].score;else items[q].cnt++;j = p;}}cout << get << endl;}sort(items + 1, items + m + 1);if(items[1].cnt == 0) cout << "Too simple";else{cout << items[1].cnt;for(int i = 1; i <= m && items[i].cnt == items[1].cnt; i++){cout << " " << items[i].id;}}return 0;
}