PAT乙级-1058 选择题 (20分)

点击链接PAT乙级-AC全解汇总

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

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

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

输入样例:

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)

输出样例:

3
6
5
2 2 3 4

我的代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#include<sstream>
using namespace std;
//有的时候题目是一起做的,所以会有不需要的头文件

int main()
{
    int N, M;
    cin >> N >> M;

    //save score and key
    //0:score 1-5:abcde 6:num_true
    int score_key[M][8];
    int wrong_times[M] = { 0 };
    int score_stu[N] = { 0 };
    memset(score_key, 0, sizeof(score_key));
    for (int i = 0; i < M; i++)
    {
        cin >> score_key[i][0];
        int options, num_true;
        cin >> options >> num_true;
        score_key[i][6] = num_true;
        for (int j = 0; j < num_true; j++)
        {
            char t;
            cin >> t;
            score_key[i][t - 'a' + 1] = 1;
        }
    }
    string s;
    getline(cin, s);
    //student answers
    for (int i = 0; i < N; i++)//第i个学生
    {
        string student;
        getline(cin, student);
        for (int j = 0; j < M; j++)//第j道题
        {
            student.erase(0, student.find('(') + 1);
            if (student[0] - '0' == score_key[j][6])
            {
                for (int k = 0; k < score_key[j][6]; k++)
                {
                    student.erase(0, student.find(' ') + 1);
                    if (!score_key[j][student[0] - 'a' + 1])
                    {
                        wrong_times[j]++;
                        break;
                    }
                    if (k == score_key[j][6]-1)
                    {
                        score_stu[i] += score_key[j][0];
                    }
                }
            }
            else
            {
                wrong_times[j]++;
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << score_stu[i] << endl;
    }

    int max_wrong = 0;
    for (int i = 0; i < M; i++)
    {
        if (wrong_times[i] > max_wrong)
            max_wrong = wrong_times[i];
    }

    if (max_wrong == 0)
    {
        cout << "Too simple";
        return 0;
    }

    cout << max_wrong;
    for (int i = 0; i < M; i++)
    {
        if (wrong_times[i] == max_wrong)
            cout << " " << i+1;
    }


    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值