批改多選題是比較麻煩的事情,有很多不同的計分方法。有一種最常見的計分方法是:如果考生選擇了部分正確選項,并且沒有選擇任何錯誤選項,則得到 50% 分數;如果考生選擇了任何一個錯誤的選項,則不能得分。本題就請你寫個程序幫助老師批改多選題,并且指出哪道題的哪個選項錯的人最多。
輸入格式:
輸入在第一行給出兩個正整數 N(≤1000)和 M(≤100),分別是學生人數和多選題的個數。隨后 M 行,每行順次給出一道題的滿分值(不超過 5 的正整數)、選項個數(不少于 2 且不超過 5 的正整數)、正確選項個數(不超過選項個數的正整數)、所有正確選項。注意每題的選項從小寫英文字母 a 開始順次排列。各項間以 1 個空格分隔。最后 N 行,每行給出一個學生的答題情況,其每題答案格式為?(選中的選項個數 選項1 ……)
,按題目順序給出。注意:題目保證學生的答題情況是合法的,即不存在選中的選項數超過實際選項數的情況。
輸出格式:
按照輸入的順序給出每個學生的得分,每個分數占一行,輸出小數點后 1 位。最后輸出錯得最多的題目選項的信息,格式為:錯誤次數 題目編號(題目按照輸入的順序從1開始編號)-選項號
。如果有并列,則每行一個選項,按題目編號遞增順序輸出;再并列則按選項號遞增順序輸出。行首尾不得有多余空格。如果所有題目都沒有人錯,則在最后一行輸出?Too simple
。
輸入樣例 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)
輸出樣例 1:
3.5
6.0
2.5
2 2-e
2 3-a
2 3-b
輸入樣例 2:
2 2
3 4 2 a c
2 5 1 b
(2 a c) (1 b)
(2 a c) (1 b)
輸出樣例 2:
5.0
5.0
Too simple
//分數 vector<int> total(m),正確選項 trueOpt[m] //每道題的選項 vector<vector<int>> cnt<m,vector<in>(5)) 漏選或者錯選項次數 //option[1100][110] 學生選的答案 #include<iostream> #include<vector> #include<set> using namespace std;int main(){int n,m;int numOption,numRight;int hash[] = {1,2,4,8,16},optStu[1100][110] = {0};//數組聲明不能放在外面??編譯錯誤char c; scanf("%d%d",&n,&m);vector<int> full_score(m),trueOption(m);vector<vector<int> > wrongCnt(m,vector<int>(5));//輸入題目信息和正確答案 for(int i = 0; i < m; i++){scanf("%d%d%d",&full_score[i],&numOption,&numRight);for(int j = 0; j < numRight; j++){//char c;scanf(" %c",&c);trueOption[i] += hash[c - 'a'];}} //輸入學生選擇信息int temp;for(int i = 0; i < n; i++){double score = 0;for(int j = 0; j < m; j++){getchar();scanf("(%d",&temp);for(int k = 0; k < temp; k++){ //輸入ith學生對于 jth道題的選擇 scanf(" %c)",&c);optStu[i][j] += hash[c - 'a'];}int el = optStu[i][j] ^ trueOption[j];if(el){ //如果異或結果不為0,意味著有錯選或者漏選的情況 //異或的結果與正確答案或運算可以求出哪個和正確結果不相同 if((optStu[i][j] | trueOption[j]) == trueOption[j]){score += full_score[j] * 1.0 / 2;}if(el){ //將錯選的選項的每一項都要統計,無論這個單項選項是否是正確的單項 for(int k = 0; k < 5; k++)if(el & hash[k]) wrongCnt[j][k]++;}}else{score += full_score[j];}}printf("%.1f\n",score);} //尋找錯誤最多的選項int maxcnt = 0;for(int i = 0; i < m; i++){for(int j = 0; j < 5; j++)maxcnt = maxcnt > wrongCnt[i][j] ? maxcnt : wrongCnt[i][j];} if(maxcnt == 0) printf("Too simple\n");else{for(int i = 0; i < m; i++){for(int j = 0; j < wrongCnt[i].size(); j++){if(maxcnt == wrongCnt[i][j])printf("%d %d-%c\n",maxcnt,i+1,'a'+j);}}}return 0; }
?