[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;
}
相关推荐
XiYang-DING4 分钟前
【LeetCode】 225.用队列实现栈
算法·leetcode·职场和发展
ybzj.27 分钟前
2025年第十六届蓝桥杯省赛C/C++大学B组 个人题解
c++
花月C27 分钟前
线性动态规划(Linear DP)
算法·动态规划·代理模式
量子炒饭大师1 小时前
【C++ 11】Cyber骇客 最后的一片净土 ——【C++11的 简单介绍 + 发展历史】历史唯物主义者带你理顺C++发展的由来
c++·dubbo·c++11
hetao17338371 小时前
2025-03-24~04-06 hetao1733837 的刷题记录
c++·算法
_深海凉_1 小时前
LeetCode热题100-环形链表
算法·leetcode·链表
原来是猿1 小时前
Linux进程信号详解(三):信号保存
开发语言·c++·算法
2401_892070981 小时前
算法与数据结构精讲:最大子段和(暴力 / 优化 / 分治)+ 线段树从入门到实战
c++·算法·线段树·最大子段和
memcpy01 小时前
LeetCode 904. 水果成篮【不定长滑窗+哈希表】1516
算法·leetcode·散列表
老四啊laosi1 小时前
[双指针] 8. 四数之和
算法·leetcode·四数之和