[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;
}
相关推荐
CSDN_RTKLIB11 分钟前
【类定义系列六】C++17新特性
开发语言·c++
hd51cc33 分钟前
MFC文件操作
c++·mfc
一条大祥脚41 分钟前
26.1.1
数据结构·算法
csuzhucong43 分钟前
圆柱三阶魔方、六棱柱魔方
算法
mit6.8241 小时前
vector<int> dfs
算法
春蕾夏荷_7282977251 小时前
Sockets-2.3.9.9 UDP使用实例
c++·udp
GetcharZp2 小时前
拒绝硬编码!C++ 配置文件管理神器 yaml-cpp 实战指南
c++
ullio2 小时前
div1+2. 2178F - Conquer or of Forest
算法
墨有6662 小时前
C++ string 部分功能详解:迭代器、初始化与常用函数
开发语言·c++