[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;
}
相关推荐
MrZhao4002 分钟前
从能跑到可用:一个 Agent Harness 还差哪些工程闭环?
算法
库克克9 分钟前
【C++】类和对象--this指针详解
java·开发语言·c++
ch0sen1pm24 分钟前
加班之余从零写了个 spdlog 风格的日志库
c++
QN1幻化引擎32 分钟前
Gravity-Anchored Cognitive Field Architecture: The DalinX V8/V10 Implementation
java·前端·算法
吃着火锅x唱着歌35 分钟前
Effective C++ 学习笔记 条款33 避免遮掩继承来的名称
c++·笔记·学习
学计算机的计算基1 小时前
LeetCode 图论四题精讲:BFS、拓扑排序、Trie 树的模板与优化
java·笔记·算法
浩瀚地学1 小时前
【面试算法笔记】0202-链表-基本功能实现
java·经验分享·笔记·算法·面试
tkevinjd1 小时前
416分割等和子集
java·python·算法·leetcode·职场和发展
Keven_111 小时前
算法札记:Tarjan与拓扑序(Topo)的关系
算法·拓扑·tarjan
库克克1 小时前
【C++】类和对象--类对象模型与大小计算
开发语言·jvm·c++