[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++基础 — 函数总结
开发语言·c++
烬羽2 小时前
递归老写崩?一个"退回"公式,把回溯题变成填空题
javascript·深度学习·算法
闪电悠米2 小时前
力扣hot100-41.缺失的第一个正数-原地哈希详解
数据结构·算法·哈希算法
星空露珠3 小时前
28种颜色对应名称,
开发语言·数据库·算法·游戏·lua
我不是懒洋洋4 小时前
从零实现一个分布式监控:Prometheus的核心设计
c++
An_s4 小时前
c++对接pdfium(一)win系统篇
开发语言·c++
众少成多积小致巨4 小时前
C++ 规范参考(上)
c++
QXWZ_IA5 小时前
桥梁数字孪生怎么落地?
人工智能·科技·算法·智能硬件·政务
Kel5 小时前
输出层与反分词(Output Layer & Detokenization)
人工智能·算法·架构
陕西企来客5 小时前
2026年7月技术好GEO优化方案:算法适配与内容策略
人工智能·算法·机器学习·技术好geo优化