[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;
}
相关推荐
Тиё Сиротака1 小时前
红包分配算法的严格数学理论与完整实现
算法
“αβ”2 小时前
MySQL表的操作
linux·网络·数据库·c++·网络协议·mysql·https
potato_may2 小时前
链式二叉树 —— 用指针构建的树形世界
c语言·数据结构·算法·链表·二叉树
十五年专注C++开发3 小时前
Asio2: 一个基于 Boost.Asio 封装的高性能网络编程库
网络·c++·boost·asio·asio2
gcfer3 小时前
CS144 中的C++知识积累
c++·右值引用·智能指针·optional容器
java修仙传3 小时前
每日一题,力扣560. 和为 K 的子数组
算法·leetcode
ada7_3 小时前
LeetCode(python)——148.排序链表
python·算法·leetcode·链表
点云SLAM3 小时前
点云配准算法之-Voxelized GICP(VGICP)算法
算法·机器人·gpu·slam·点云配准·vgicp算法·gicp算法
Bona Sun4 小时前
单片机手搓掌上游戏机(二十)—pico运行doom之编译环境
c语言·c++·单片机·游戏机
Albert Edison4 小时前
【项目设计】C++ 高并发内存池
数据结构·c++·单例模式·哈希算法·高并发