[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;
}
相关推荐
zc.ovo5 分钟前
河北师范大学2026校赛题解(A,E,I)
c++·算法
py有趣12 分钟前
力扣热门100题之环形链表
算法·leetcode·链表
py有趣24 分钟前
力扣热门100题之回文链表
算法·leetcode·链表
学嵌入式的小杨同学1 小时前
STM32 进阶封神之路(三十九)FreeRTOS 临界区、挂起 / 删除、钩子函数、调度底层原理|从应用到内核深度解析
c++·stm32·单片机·嵌入式硬件·mcu·硬件架构·pcb
oioihoii1 小时前
Cursor根本无法调试C++
开发语言·c++
月落归舟2 小时前
帮你从算法的角度来认识二叉树---(二)
算法·二叉树
SilentSlot3 小时前
【数据结构】Hash
数据结构·算法·哈希算法
是娇娇公主~4 小时前
Lambda表达式详解
数据结构·c++
leaves falling4 小时前
C++ string 类:从入门到模拟实现
开发语言·c++