当前位置:网站首页>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;
}
边栏推荐
- Zotero期刊自动匹配更新影响因子
- One hour to build a sample scenario sound network to release lingfalcon Internet of things cloud platform
- Flume configuration 1 - basic case
- File contains vulnerability
- Linux安装MySQL5
- Sword finger offer 59 - ii Maximum value of the queue
- 苹果iPhone手机升级系统内存空间变小不够如何解决?
- 【剑指Offer】51. 数组中的逆序对
- 2022年深圳市福田区支持招商引资若干政策
- 【编译原理】语义分析
猜你喜欢

3-2 host discovery - layer 3 discovery

Flume配置3——拦截器过滤

4-1 port scanning technology

MySQL remote connection

【编译原理】语义分析

Flume配置4——自定义Source+Sink

【网络方向实训】-企业园区网络设计-【Had Done】

Linux安装MySQL5

Configuration du Flume 4 - source personnalisée + sink

Detailed description of gaussdb (DWS) complex and diverse resource load management methods
随机推荐
第二章(物理层)
Measures to support the development of advanced manufacturing industry in Futian District of Shenzhen in 2022
One hour to build a sample scenario sound network to release lingfalcon Internet of things cloud platform
Software engineering - principles, methods and Applications
PowerShell command outputs only a list of directories
一个mysql里有3306端口下,一个mysql有20多个数据库,怎么一键备份20多个数据库,做系统备份,防止数据误删除?
WPS and Excelle
data link layer
Nutch2.1分布式抓取
【精品】pinia详解
Jmeter之BeanShell详解和夸线程调用
Zotero journal Automatic Matching Update Influencing Factors
Union find
jfinal中如何使用过滤器监控Druid监听SQL执行?
Three.js开发:粗线的画法
Flume配置4——自定義Source+Sink
Following the crowd hurts you
文件包含漏洞
Sword finger offer 41 Median in data stream
There are more than 20 databases in a MySQL with 3306 ports. How can I backup more than 20 databases with one click and do system backup to prevent data from being deleted by mistake?