当前位置:网站首页>2021 CCPC 哈尔滨 J. Local Minimum (思维题)
2021 CCPC 哈尔滨 J. Local Minimum (思维题)
2022-06-29 20:03:00 【GHOSTANDBREAD】
思路:
一个数是它所在行和所在列的最小值,则这个数即为要找的数。要找出矩阵中一共有多少个这样的数。可以先找出每一行和每一列的最小值,如果两者都为a[i][j],则a[i][j]即为一个要找的数,res++
代码:
#include<iostream>
#include<cstring>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int a[1005][1005];
int h[1005], l[1005];
int res;
int main() {
int n, m;
scanf("%d%d", &n, &m);
memset(h, 0x3f, sizeof h);
memset(l, 0x3f, sizeof l);
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) {
scanf("%d", &a[i][j]);
if(h[i] > a[i][j]) h[i] = a[i][j];
if(l[j] > a[i][j]) l[j] = a[i][j];
}
}
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) {
if(a[i][j] == h[i] && a[i][j] == l[j])
res ++;
}
}
cout << res;
return 0;
}
边栏推荐
- 【编译原理】语法分析
- La collection numérique Meng xiangshun, artiste national du tigre peint, est disponible en quantité limitée et est offerte avec Maotai de l'année du tigre
- Zotero期刊自動匹配更新影響因子
- 【剑指Offer】51. 数组中的逆序对
- proxmox集群节点崩溃处理
- 【摸鱼神器】UI库秒变低代码工具——表单篇(一)设计
- Detailed description of gaussdb (DWS) complex and diverse resource load management methods
- Common knowledge of ECS security settings
- Zotero期刊自动匹配更新影响因子
- 剑指 Offer 59 - II. 队列的最大值
猜你喜欢

Koa source code analysis

Sentinel的快速入门,三分钟带你体验流量控制

【摸鱼神器】UI库秒变低代码工具——表单篇(一)设计

Flutter calls Baidu map app to realize location search and route planning

一个mysql里有3306端口下,一个mysql有20多个数据库,怎么一键备份20多个数据库,做系统备份,防止数据误删除?

npm ERR! fatal: early EOF npm ERR! fatal: index-pack failed

As the "only" privacy computing provider, insight technology is the "first" to settle in the Yangtze River Delta data element circulation service platform

CorelDRAW最新24.1.0.360版本更新介绍讲解

How to set a pod to run on a specified node

Detailed description of gaussdb (DWS) complex and diverse resource load management methods
随机推荐
freemarker模板框架生成图片
社区访谈丨一个IT新人眼中的JumpServer开源堡垒机
偶然发现了另一种跨域方式,不知道有没有人这么玩过
Flume configuration 3 - interceptor filtering
Summary of swift optional values
画虎国手孟祥顺数字藏品限量发售,随赠虎年茅台
Flume configuration 1 - basic case
Measures to support the development of advanced manufacturing industry in Futian District of Shenzhen in 2022
Community interview -- jumpserver open source fortress in the eyes of an it newcomer
.NetCore统一认证授权学习——Run(1)
Dynamics CRM: 本地部署的服务器中, Sandbox, Unzip, VSS, Asynchronous还有Monitor服务的作用
Three.js开发:粗线的画法
7.取消与关闭
Oracle11.2.0.4-rac cluster hang analysis record
3-2 host discovery - layer 3 discovery
In 2022, the financial interest rate has dropped, so how to choose financial products?
Flume配置2——监控之Ganglia
Sword finger offer 59 - ii Maximum value of the queue
[notes] take notes again -- learn by doing Verilog HDL – 008
雪花id,分布式唯一id