[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;
}
相关推荐
我想走路带风2 小时前
各自缓冲及实现
c++
青 春 记 忆2 小时前
LeetCode 53. 最大子数组和|Python 解法详解
python·算法·leetcode
豆瓣鸡3 小时前
算法日记 - Day10
算法
戴西软件3 小时前
戴西CAxWorks.VPG车辆工程仿真软件技术解析(上)——安全仿真体系的自动化构建
运维·网络·数据库·人工智能·算法·安全·自动化
zander2583 小时前
4. 寻找两个正序数组的中位数:用分割点代替合并
数据结构·算法
Kisorge3 小时前
【电机控制器】 基于STSPIN32G4的FOC控制
stm32·嵌入式硬件·算法
阿米亚波3 小时前
【C/C++包管理器】vcpkg(by microsoft)
c语言·c++·git·vscode·microsoft·github·vcpkg
Elivs3 小时前
RMSNorm函数
人工智能·算法·机器学习
tudousisi2224 小时前
P4447 [AHOI2018初中组] 分组 题解复盘
算法
SNAKEpc121384 小时前
OpenGL(十一)- 变换管线
c语言·c++·算法·矩阵·图形渲染