[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 分钟前
华为题:盛最多水的容器
数据结构·算法
sanqima7 分钟前
CreateThread、_beginthreadex、AfxBeginThread三种线程创建的区别与联系
c++·tls·线程创建
怦然丶心动8 分钟前
用 Java 把干支历法算清楚:从节气切年到可读摘要
java·算法·vue·独立开发·spring boot / spring
sanqima14 分钟前
依赖TLS和模块状态的MFC类
c++·mfc·tls·module state
Zachery Pole19 分钟前
具身智能强化学习(1)引言
算法·机器学习
All for pursuit.21 分钟前
【动态规划-11】279.完全平方数
数据结构·c++·算法·leetcode·动态规划
淡海水28 分钟前
02-06-原理篇-增量式GC与并发GC
算法·unity·c#·并发·gc·增量
对空六课30 分钟前
无头浏览器访问对跳出率的过滤规则
服务器·前端·算法·数据分析
有同事要进步31 分钟前
leecode第一题-两数字之和(打卡)
算法
程序员清风36 分钟前
二叉搜索树:查找、插入与删除
算法