[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;
}
相关推荐
风筝在晴天搁浅12 分钟前
美团 LeetCode 692.前K个高频单词
算法·leetcode·职场和发展
酿情师13 分钟前
Microsoft Visual C++ Build Tools 2026 下载与安装指南(Windows)
c++·windows·microsoft
cany100030 分钟前
C++ -- 引用悬挂
c++
地平线开发者34 分钟前
量化训练时 fusebn/withbn 简介
算法·自动驾驶
不做无法实现的梦~41 分钟前
MAVLink 协议教程
linux·stm32·嵌入式硬件·算法
.千余1 小时前
【C++】C++类与对象3:const成员函数与取地址运算符重载,权限管理的艺术
开发语言·c++
墨白曦煜1 小时前
算法实战笔记:剥开回溯算法的外衣——从通用模板到高阶去重(八)
笔记·算法
z200509301 小时前
今日算法(回溯子集)(模版题)
数据结构·算法·leetcode
吴佳浩1 小时前
Vibe Coding 时代,研发经理为何越来越值钱?
算法·架构
IronMurphy1 小时前
【算法五十四】72. 编辑距离
算法