1058 选择题

/**
 * 1.解题思路:顺序查看注释
 * 
 * 2.参考博客:https://blog.csdn.net/liuchuo/article/details/52510582
 **/
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
int main() {
    //n个学生,m道题目
    int n, m, temp, k;
    scanf("%d%d", &n, &m);
    //题目的选项插入存储在right[i](为集合类型)里面
    vector<set<char>> right(m);
    //题目的总分存储在total[i]
    //wrongCnt[i]存储第i道题错误的人数
    vector<int> total(m), wrongCnt(m);
    for(int i = 0; i < m; i++) {
        // 题目总分 选项个数 正确选项个数
        scanf("%d%d%d", &total[i], &temp, &k);
        for(int j = 0; j < k; j++) {
            char c;
            scanf(" %c", &c);
            right[i].insert(c);
        }
    }
    for(int i = 0; i < n; i++) {
        int score = 0;
        scanf("\n");
        for(int j = 0; j < m; j++) {
            //首尾没有空格
            if(j != 0) scanf(" ");
            //学生选中的选项个数
            scanf("(%d", &k);
            //学生的选项
            set<char> st;
            char c;
            for(int l = 0; l < k; l++) {
                scanf(" %c", &c);
                st.insert(c);
            }
            scanf(")");
            //比较st与right[i]是否相等
            //如果相等说明该生答对了
            //他的score += total[i](加上当前题目的总分)
            if(st == right[j]) {
                score += total[j];
            } else {
                //wrongCnt[i]++,表示第i道题新增一个错误的人
                wrongCnt[j]++;
            }
        }
        printf("%d\n", score);
    }
    //输出错得最多的题目的错误次数和编号
    int maxWrongCnt = 0;
    for(int i = 0; i < m; i++) {
        if(wrongCnt[i] > maxWrongCnt) {
            maxWrongCnt = wrongCnt[i];
        }
    }
    if(maxWrongCnt == 0)
        printf("Too simple");
    else {
        printf("%d", maxWrongCnt);
        //题目按照输入的顺序从1开始编号
        //若有并列,则按编号递增顺序输出
        for(int i = 0; i < m; i++) {
            if(wrongCnt[i] == maxWrongCnt) {
                printf(" %d", i + 1);
            }
        }
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值