[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;
}
相关推荐
满天星83035773 分钟前
【算法】最长递增子序列(三种解法)
算法
hold?fish:palm6 分钟前
kv存储主从复制的设计与实现
c++·redis·后端
啦啦啦啦啦zzzz42 分钟前
算法:贪心算法
c++·算法·leetcode·贪心算法
charlie1145141911 小时前
现代C++工程实践 WeakPtr 实战(三):WeakPtrFactory 与「最后成员」惯用法
开发语言·c++·开源项目·现代c++
清泓y2 小时前
RAG 技术
算法·ai
阿慧今天瘦了嘛2 小时前
计算机组成原理概述:从硬件到软件的桥梁
计算机网络·算法
JetComXCpp3 小时前
给 Win32 窗口加上毛玻璃效果——纯 D3D11 实现,零依赖
c++
网站优化(SEO)专家3 小时前
SEO核心算法拆解:网站排名快速提升的武林秘籍!
算法·搜索引擎·网站排名·核心算法
惊讶的猫3 小时前
CLGSI
人工智能·算法·机器学习
ysa0510304 小时前
【板子】二分答案(最大最小?)
c++·笔记·算法·板子