T7 道法考试

来源:【LGR-182-Div.4】洛谷入门赛 #22

PS:由于本题复制较困难,今天工作电脑又不好截屏,于是本篇只附上题解,题目另篇上传,敬请谅解~

#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<unordered_set<int>> answers(n);
    vector<int> scores(n, 0);

    // 读取标准答案
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int knowledge_point;
            cin >> knowledge_point;
            answers[i].insert(knowledge_point);
        }
    }

    // 读取作答并计分
    for (int i = 0; i < n; ++i) {
        int num_answers;
        cin >> num_answers;

        unordered_set<int> user_answer;
        for (int j = 0; j < num_answers; ++j) {
            int knowledge_point;
            cin >> knowledge_point;
            user_answer.insert(knowledge_point);
        }

        // 检查是否作答包含标准答案的所有知识点
        bool correct = true;
        for (int knowledge_point : answers[i]) {
            if (user_answer.find(knowledge_point) == user_answer.end()) {
                correct = false;
                break;
            }
        }

        // 根据是否正确计分
        if (correct) {
            scores[i] = 2;
        }
    }

    // 计算总分
    int total_score = 0;
    for (int score : scores) {
        total_score += score;
    }

    cout << total_score << endl;

    return 0;
}

本次比赛(【LGR-182-Div.4】洛谷入门赛 #22)共8题,我们上传的两道题都是AC的,本题分更是超了1000分~

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值