[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;
}
相关推荐
朔北之忘 Clancy3 小时前
2025 CSP-J 第二轮真题解析
c++·青少年编程·题解·noip·csp·信奥赛·noi
longlongzihan3 小时前
LeetCode 17电话号码的字母组合:回溯算法(DFS)详解
c++·算法·leetcode·深度优先
yolo_guo3 小时前
调试mysql延迟与libevent回调实际发送回复时机问题
c++·mysql·libevent
封印师请假去地球钓鱼3 小时前
边解边变的问题:从“决策依赖“一词出发
人工智能·算法
今晚打老虎4 小时前
c++之提高A(前缀和)(第三课)
数据结构·c++·算法
不会就选b5 小时前
算法日常・每日刷题--<贪心>26
数据结构·算法
by209995 小时前
从结构体到对象:正式学习C++类的骨架、封装与this指针
c++·经验分享·学习
2601_962218616 小时前
C语言中三种库的编译和使用方法
开发语言·c++
jimy16 小时前
派生类重写基类虚函数(二):override的作用
开发语言·c++
ebiobiz7 小时前
基于 GD32 Embedded Builder (GEB) 与 Nimmake 的 MCU 工程搭建指南
c++·python·单片机·嵌入式硬件·mcu