[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;
}
相关推荐
小白杨树树19 分钟前
【C++】力扣hot100错误总结
c++·leetcode·c#
ajassi200034 分钟前
开源 C++ QT QML 开发(二十三)程序发布
c++·qt·mfc
筱砚.1 小时前
【STL——stack容器】
开发语言·c++
我是华为OD~HR~栗栗呀2 小时前
华为od-22届考研-测试面经
java·c++·python·功能测试·华为od·华为·面试
康谋自动驾驶2 小时前
拆解3D Gaussian Splatting:原理框架、实战 demo 与自驾仿真落地探索!
算法·数学建模·3d·自动驾驶·汽车
沐怡旸2 小时前
【穿越Effective C++】条款3:尽可能使用const ——C++不变性的艺术
c++
哼?~3 小时前
C++之智能指针
开发语言·c++
violet-lz3 小时前
数据结构八大排序:希尔排序-原理解析+C语言实现+优化+面试题
数据结构·算法·排序算法
mjhcsp3 小时前
C++ long long 类型深度解析:大整数处理的基石
开发语言·c++·策略模式·long long