# PAT (Basic Level) Practice (Chinese) 1058 multiple choice questions (20 points)

## Title Description

It is more troublesome to correct multiple-choice questions. This topic asks you to write a program to help the teacher correct multiple-choice questions and to point out which one has the most errors.

### Input Format

The input gives two positive integers, N (< 1000) and M (< 100), on the first line, which are the number of students and the number of multiple choices. Subsequently, in M lines, each line gives the full score of a question (no more than 5 positive integers), the number of options (no less than 2 and no more than 5 positive integers), the number of correct options (no more than 5 positive integers), and all the correct options. Note that the options for each question are arranged in order starting with the lowercase letter A. Each item is separated by a space. At the end of line N, each line gives a student's answer in the form of (1... for the number of options selected), given in the order of the questions. Note: The Title guarantees that the students'answers are legitimate, that is, there is no situation where the number of selected options exceeds the actual number of options.

### Output Format

Each student's score is given in the order entered, with each score on a line. Note that only when you select all the right questions can you get the score for the question. The last line outputs the number and number of errors for the title with the most errors (titles are numbered from 1 in the order entered). If there are parallel columns, the output is numbered incrementally. Numbers are separated by spaces, and no extra space is allowed at the beginning or end of the line. If none of the topics are wrong, output Too simple on the last line.

### sample input

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) (2 b d) (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) (2 b c) (4 a b c d)

### sample output

3 6 5 2 2 3 4

## Solving problems

Since there are up to five options for each question, and each option has two states of selection and selection, it can be expressed in binary form (that is, 0--31 represents 32 states).

From right to left, a,b,c,d,e, so if you read an answer, you can use the left shift operation to get the one you want.

char c; flag|=(1<<(c-'a'));

Each student's answer to each question can also be expressed in this way

The answer differs from the student's answer to a question. A result of 0 indicates that each is the same and the answer is correct. Otherwise the answer is wrong

The most disgusting part of this question is reading characters

## AC Code

#include<iostream> #include<vector> #include<algorithm> using namespace std; struct QuesNode{ int score,options,wrongCnt,id; //Binary, starting with the first option a, expressed in 0--31 int flag; QuesNode():flag(0),wrongCnt(0){} }; bool cmp(QuesNode a,QuesNode b){ if(a.wrongCnt == b.wrongCnt) return a.id<b.id; return a.wrongCnt>b.wrongCnt; } int main(){ int N,M; cin >> N >> M; vector<QuesNode> v(M); for(int i=0;i<M;i++){ //Record answers int tmp; v[i].id = i+1; //Record Title id cin >> v[i].score >> v[i].options >> tmp; for(int j=0;j<tmp;j++){ char c; getchar(); cin >> c; (v[i].flag)|=(1 << (c-'a')); } } //Decision, because each question has a binary representation, either zero or zero for(int j = 0;j<N;j++){ //Traverse once per student int sum = 0; //Record each student's score for(int i=0;i<M;i++){ //One question, one batch getchar(); //Swallow line breaks or leading spaces above getchar(); //Swallow the first ( char c; int flag = 0; int tmp; cin >> tmp; for(int k=0;k<tmp;k++){ //Read in each option getchar(); cin >> c; flag|=(1<<(c-'a')); } if(flag^v[i].flag){ //XOR OR NOT ZERO, Wrong v[i].wrongCnt++; }else{ sum+=v[i].score; } getchar(); //Swallow) } cout << sum << endl; } sort(v.begin(),v.end(),cmp); int maxWrongCnt = v[0].wrongCnt; if(maxWrongCnt==0) cout << "Too simple" <<endl; else{ cout << maxWrongCnt; for(auto it = v.begin();it!=v.end();it++){ if(it->wrongCnt==maxWrongCnt) cout << " " << it->id; else break; } } return 0; }