[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;
}
相关推荐
wabs66619 小时前
关于贪心算法的思考
算法·贪心算法
社交怪人19 小时前
【判断大小】信息学奥赛一本通C语言解法(题号1043)
算法
Snasph19 小时前
GNU Make 用户手册(中文版)
服务器·算法·gnu
江澎涌20 小时前
拆解与 AI 的一次对话
人工智能·算法·程序员
sheeta199820 小时前
LeetCode 每日一题笔记 日期:2026.06.02 题目:3635. 最早完成陆地和水上游乐设施的时间 II
笔记·算法·leetcode
Lsk_Smion20 小时前
力扣实训 _ [102].层序遍历--前序--后续_递归与非递归的实现
数据结构·算法·leetcode
小欣加油1 天前
leetcode3751 范围内总波动值I
java·数据结构·c++·算法·leetcode
代码中介商1 天前
C++左值与右值:核心判断法则详解
开发语言·c++
玖玥拾1 天前
C/C++ 基础笔记(七)
c语言·c++
Halo_tjn1 天前
反射与设计模式1
java·开发语言·算法