[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;
}
相关推荐
王德博客12 小时前
【题解】求分数序列(C++)
算法
x70x8012 小时前
C++中不同容器的用法及接口(vector / deque / stack / queue / priority_queue)
开发语言·c++
再__努力1点12 小时前
LBP纹理特征提取:高鲁棒性的纹理特征算法
开发语言·人工智能·python·算法·计算机视觉
ZPC821012 小时前
PPO算法训练机器人时,如何定义状态/动作/奖励
人工智能·算法·机器人
永远都不秃头的程序员(互关)13 小时前
数据结构实战:从复杂度到C++实现
算法
努力学算法的蒟蒻13 小时前
day42(12.23)——leetcode面试经典150
算法·leetcode·面试
鹿角片ljp13 小时前
力扣226.翻转二叉树-递归
数据结构·算法·leetcode
TechNomad13 小时前
排序算法:归并排序算法
算法·排序算法
qq_3106585113 小时前
janux源码走读(五)Janus事件处理模块(events/)
服务器·c++·音视频
WBluuue13 小时前
数据结构和算法:Morris遍历
数据结构·c++·算法