首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

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

  • 24-02-22 06:41
  • 3552
  • 11452
blog.csdn.net

点击链接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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

输出样例:

3
6
5
2 2 3 4
  • 1
  • 2
  • 3
  • 4

我的代码:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
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;
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
注:本文转载自blog.csdn.net的邂逅模拟卷的文章"https://blog.csdn.net/qq_34451909/article/details/104867689"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2492) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

101
推荐
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2025 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top