批改多选题是比较麻烦的事情,本题就请你写个程序帮助老师批改多选题,并且指出哪道题错的人最多。

输入格式:

输入在第一行给出两个正整数 N(≤ 1000)和 M(≤ 100),分别是学生人数和多选题的个数。随后 M 行,每行顺次给出一道题的满分值(不超过 5 的正整数)、选项个数(不少于 2 且不超过 5 的正整数)、正确选项个数(不超过选项个数的正整数)、所有正确选项。注意每题的选项从小写英文字母 a 开始顺次排列。各项间以 1 个空格分隔。最后 N 行,每行给出一个学生的答题情况,其每题答案格式为 (选中的选项个数 选项1 ……),按题目顺序给出。注意:题目保证学生的答题情况是合法的,即不存在选中的选项数超过实际选项数的情况。

输出格式:

按照输入的顺序给出每个学生的得分,每个分数占一行。注意判题时只有选择全部正确才能得到该题的分数。最后一行输出错得最多的题目的错误次数和编号(题目按照输入的顺序从 1 开始编号)。如果有并列,则按编号递增顺序输出。数字间用空格分隔,行首尾不得有多余空格。如果所有题目都没有人错,则在最后一行输出 Too simple

输入样例:

  1. 3 4
  2. 3 4 2 a c
  3. 2 5 1 b
  4. 5 3 2 b c
  5. 1 5 4 a b d e
  6. (2 a c) (2 b d) (2 a c) (3 a b e)
  7. (2 a c) (1 b) (2 a b) (4 a b d e)
  8. (2 b d) (1 e) (2 b c) (4 a b c d)

输出样例:

  1. 3
  2. 6
  3. 5
  4. 2 2 3 4

代码

测试点4未通

  1. #include<cstdio>
  2. #include<cstring>
  3. struct Problem {
  4. int itemNum;
  5. int score;
  6. int correctNum;
  7. char answer[6];
  8. Problem() {
  9. for (int i = 0; i < 6; i++)
  10. answer[i] = { '\0' };
  11. }
  12. };
  13. struct Student {
  14. int score;
  15. int itemNum;
  16. int correctNum;
  17. Student() {
  18. score = 0;
  19. itemNum = 0;
  20. correctNum = 0;
  21. }
  22. };
  23. int main() {
  24. int stuNum, problemNum;
  25. scanf("%d%d", &stuNum, &problemNum);
  26. /** Read the problem information */
  27. Problem* pro = new Problem[problemNum];
  28. for (int i = 0; i < problemNum; i++) {
  29. scanf("%d%d%d", &pro[i].score, &pro[i].itemNum, &pro[i].correctNum);
  30. int temp = 0;
  31. while (temp != pro[i].correctNum)
  32. scanf(" %c", &pro[i].answer[temp++]);
  33. }
  34. int* statistics = new int[problemNum];
  35. for (int i = 0; i < problemNum; i++) { /* Initialize the statistics array */
  36. statistics[i] = 0;
  37. }
  38. /** Read the student information */
  39. Student* stu = new Student[stuNum];
  40. int wrongCounter = 0;
  41. for (int i = 0; i < stuNum; i++) {
  42. char stuAns[10001] = {'\0'};
  43. getchar(); /* Absort the '\n' */
  44. scanf("%[^\n]", stuAns);
  45. for (int j = 0; j < problemNum; j++) {
  46. stu[i].itemNum = 0;
  47. stu[i].correctNum = 0;
  48. sscanf(stuAns, "(%d", &stu[i].itemNum);
  49. if (stu[i].itemNum != pro[j].correctNum) {
  50. stu[i].score += 0;
  51. statistics[j]++;
  52. wrongCounter++;
  53. continue;
  54. }
  55. char stuItem[101] = {'\0'}; /* Read the student's each item */
  56. sscanf(stuAns, "%[^')']", stuItem);
  57. for (int k = 0; k < strlen(stuItem); k++) {
  58. if (stuItem[k] >= 'a' && stuItem[k] <= 'z') {
  59. for (int x = 0; x < pro[j].correctNum; x++) {
  60. if (stuItem[k] == pro[j].answer[x]) {
  61. stu[i].correctNum++;
  62. break;
  63. }
  64. }
  65. }
  66. }
  67. strcpy(stuAns, stuAns + (stu[i].itemNum * 2 + 4)); /* Pointer move right to next problem */
  68. if (stu[i].correctNum == pro[j].correctNum)
  69. stu[i].score += pro[j].score;
  70. else {
  71. stu[i].score += 0;
  72. statistics[j]++;
  73. wrongCounter++;
  74. }
  75. }
  76. printf("%d\n", stu[i].score);
  77. }
  78. int MAX = 0;
  79. for (int i = 0; i < problemNum; i++) {
  80. if (statistics[i] > MAX) MAX = statistics[i];
  81. }
  82. if (wrongCounter) {
  83. printf("%d", MAX);
  84. for (int i = 0; i < problemNum; i++)
  85. if (statistics[i] == MAX) printf(" %d", i + 1);
  86. }
  87. else
  88. printf("Too simple\n");
  89. delete[] pro;
  90. delete[] stu;
  91. return 0;
  92. }