[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;
}
相关推荐
2301_803554529 分钟前
c++hpc岗位
c++
坐怀不乱杯魂12 分钟前
Linux - 线程
linux·c++
DuHz15 分钟前
UWB 雷达综述精读:应用、标准、信号处理、数据集、芯片与未来方向——论文阅读
论文阅读·学习·算法·信息与通信·信号处理
diediedei23 分钟前
C++中的适配器模式变体
开发语言·c++·算法
Timmylyx051826 分钟前
Codeforces Round 1075 (Div. 2) 题解
算法·codeforces·比赛日记
hadage23334 分钟前
--- 力扣oj柱状图中最大的矩形 单调栈 ---
算法·leetcode·职场和发展
json{shen:"jing"}35 分钟前
18. 四数之和
数据结构·算法·leetcode
千逐-沐风35 分钟前
SMU-ACM2026冬训周报1st
算法
天赐学c语言36 分钟前
1.25 - 零钱兑换 && 理解右值以及move的作用
c++·算法·leecode
北冥湖畔的燕雀38 分钟前
C++智能指针:告别内存泄漏的利器
c++·算法