[2023年12月17日]第15届蓝桥杯青少组stema选拔赛C++中高级(第二子卷、编程题(3))

参考程序:

cpp 复制代码
#include <iostream>
#include <set>
using namespace std;

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

    set<int> filledRows, filledCols;

    // 读取被填色的行号
    for (int i = 0; i < x; i++) {
        int row;
        cin >> row;
        filledRows.insert(row);  // 将填色的行添加到集合中
    }

    // 读取被填色的列号
    for (int i = 0; i < y; i++) {
        int col;
        cin >> col;
        filledCols.insert(col);  // 将填色的列添加到集合中
    }

    // 计算未填色的行和列的数量
    int unfilledRows = n - filledRows.size();  // 未填色的行数
    int unfilledCols = m - filledCols.size();  // 未填色的列数

    // 未填色的小方格数量
    int unfilledSquares = unfilledRows * unfilledCols;

    cout << unfilledSquares << endl;  // 输出结果
    return 0;
}
相关推荐
方方洛9 分钟前
vllm教程-00-前言与导读
人工智能·算法·vllm
IT毕设实战小研26 分钟前
电影数据可视化推荐系统
大数据·后端·爬虫·python·算法·信息可视化·课程设计
且随疾风前行.30 分钟前
从驱动来分析服务的添加过程
算法
zl.rs35 分钟前
配置更适合生产环境的coredump
c++
CoderYanger1 小时前
A.每日一题:输入单词需要的最少按键次数 Ⅰ+Ⅱ
java·数据结构·算法·leetcode·面试
一木 之林1 小时前
三.C++ 内存管理(进阶)(二)
开发语言·arm开发·c++
DLite1 小时前
开源一个静态类型语言——NLang
c++·编译器·nlang
uoKent2 小时前
c++中new和malloc的区别
java·jvm·c++
xiaokcehui2 小时前
地球物理大地测量学计算系列之十七局部重力场SRBF逼近及其性能指标测评
人工智能·算法·机器学习
会周易的程序员2 小时前
aiDgeController 软PLC虚拟机stvm集成测试报告
c++·物联网·架构·集成测试·st·软plc·iec61131