[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;
}
相关推荐
Jayden_Ruan6 分钟前
C++组合的输出
c++·算法·深度优先
什巳1 小时前
JAVA练习312- 二叉搜索树中第 K 小的元素
java·数据结构·算法·leetcode
froyoisle1 小时前
CSP 真题解析:[CSP-J 2020-T3] 表达式
c++·算法·csp·信息学·信奥赛
geats人山人海1 小时前
算法好题 2026.7.18
算法
Darkwanderor1 小时前
动、静态库相关内容的详细介绍
linux·c语言·开发语言·c++
文祐1 小时前
C++类之虚函数表没有虚继承的菱形继承
开发语言·c++·算法
Lumos1861 小时前
51单片机从零到实战(8)——串口通信
算法
小帽子_1232 小时前
大功率 PCS 双环闭环控制算法原理与实现
算法
buhuizhiyuci3 小时前
【算法篇】位运算 —— 基础篇
java·数据库·算法
Black蜡笔小新3 小时前
算法训练完了怎么上线?DLTM→AIS→EasyGBS三步交付流水线
人工智能·算法