Correcting multiple-choice questions is a troublesome thing. There are many different scoring methods. One of the most common scoring methods is: if the examinee selects some correct options and does not select any wrong options, he will get a 50% score; If the candidate chooses any of the wrong options, he will not be able to score. Please write a program to help the teacher correct multiple-choice questions and point out which of the questions has the most wrong choices.
Input format:
Input two positive integers N (≤ 1000) and M (≤ 100) are given in the first line, which are the number of students and the number of multiple topics respectively. Then, in line M, the full score of a question (a positive integer not exceeding 5), the number of options (a positive integer not less than 2 and not more than 5), the number of correct options (a positive integer not exceeding the number of options), and all correct options are given in sequence in each line. Note that the options of each question are arranged in order starting from the English letter A. Items are separated by 1 space. In the last N lines, each line gives a student's answer, and the answer format of each question is (number of selected options, option 1...) are given in the order of topics. Note: the questions ensure that students' answers are legal, that is, there is no case where the number of selected options exceeds the actual number of options.
Output format:
The scores of each student are given in the order of input. Each score occupies one line and outputs one decimal place. Finally, the information of the most wrong topic option is output in the format of: number of errors, topic number (topics are numbered from 1 in the input order) - option number. If there is juxtaposition, one option for each line will be output in ascending order of topic number; If they are juxtaposed again, they will be output in ascending order of option number. There must be no extra spaces at the beginning and end of the line. If all the questions are correct, output them on the last line Too simple.
Input example 1:
3 4 3 4 2 a c 2 5 1 b 5 3 2 b c 1 5 4 a b d e (2 a c) (3 b d e) (2 a c) (3 a b e) (2 a c) (1 b) (2 a b) (4 a b d e) (2 b d) (1 e) (1 c) (4 a b c d)
Output example 1:
3.5 6.0 2.5 2 2-e 2 3-a 2 3-b
Input example 2:
2 2 3 4 2 a c 2 5 1 b (2 a c) (1 b) (2 a c) (1 b)
Output example 2:
5.0 5.0 Too simple
#include <iostream> #include <vector> #include <map> #include <algorithm> #include <iomanip> using namespace std; int main() { int n, m, maxx = 0; //Maximum number of errors cin >> n >> m; double score[110] = {0}; //Full score of each question vector<vector<char>>v;//Correct answer to each question double total[1010] = {0}; //Score per student map<string, int>s; //Count the number of errors in each option of each question for (int i = 0; i < m; i++) { int x;//Number of correct options int b;//Number of options cin >> score[i] >> b >> x; for (int j = 0; j < b; j++) { string str = to_string(i + 1) + '-' + (char)('a' + j); s.insert(make_pair(str, 0)); } vector<char>v1(x); for (int j = 0; j < x; j++) { cin >> v1[j]; } v.push_back(v1); } int y;//Number of options for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { bool flag = 0; getchar(); scanf("("); cin >> y; vector<char>v2(y);//Record student answers for (int k = 0; k < y; k++) { cin >> v2[k]; if (find(v[j].begin(), v[j].end(), v2[k]) == v[j].end()) { flag = 1; string str = to_string(j + 1) + '-' + v2[k]; s[str]++; if (maxx < s[str]) { maxx = s[str]; } } } scanf(")"); for (int k = 0; k < v[j].size(); k++) { if (find(v2.begin(), v2.end(), v[j][k]) == v2.end()) { string str = to_string(j + 1) + '-' + v[j][k]; s[str]++; if (maxx < s[str]) { maxx = s[str]; } } } if (flag == 0 && y == v[j].size()) { total[i] += score[j]; } else if (flag == 0 && y < v[j].size()) { total[i] += score[j] / 2; } } } for (int i = 0; i < n; i++) { cout << setprecision(1) << fixed << total[i] << endl; } if (maxx == 0) { cout << "Too simple"; } else { int num = 0; for (map<string, int>::iterator it = s.begin(); it != s.end(); it++) { if (it->second == maxx) { num++; } } int cnt = 0; for (map<string, int>::iterator it = s.begin(); it != s.end(); it++) { if (it->second == maxx) { cout << maxx << ' ' << it->first; cnt++; if (cnt != num) { cout << endl; } } } } return 0; }
At first, test point 4 couldn't pass. Later, it was found that because the problem number was greater than one digit, the method of '0'+j was directly used to convert int to string, and then to_string was solved because there were few data at the first few test points, which did not happen. Test point 4 was a big data test, and the problem was reflected at once. It may be because the simulation was written a little around. It was changed from morning to night for test point 4 all day, and such an obvious problem was not found. I'm really stupid and I'm really happy.