[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;
}
相关推荐
纪念 2293 分钟前
C++ 算法模板与错题 (前缀和)
开发语言·c++·算法
罗西的思考11 分钟前
【轻量化复刻大模型 / π0.5】(4)处理输入
人工智能·算法·机器学习
饮水桶_T42 分钟前
DUNE:基于依赖图传播的Agent派生记忆一致性更新机制 笔记
开发语言·笔记·算法·电脑
Navigator_Z1 小时前
LeetCode //C - 1332. Remove Palindromic Subsequences
c语言·算法·leetcode
Code_Solitude1 小时前
c语言:期末复习(7)
c语言·开发语言·算法
潇湘散客1 小时前
PlantAis插件更新:RVM负实体开关;VUE文件读取与导出等
c++·qt·opengl
金榜题名萱1 小时前
蓝桥杯 - 旗帜
c语言·数据结构·c++·算法·蓝桥杯
俊俊几年的2 小时前
RK3588 硬件架构详解:CPU、GPU、NPU 与 RKNN 软件栈
linux·c++·python·yolo·numpy·rockchip
不知棋者2 小时前
C++ 排序算法大全
开发语言·c++·排序算法