当前位置:网站首页>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;
}
边栏推荐
- 【摸鱼神器】UI库秒变低代码工具——表单篇(一)设计
- Finally, Amazon~
- NLP - GIZA++ 实现词对齐
- 【Try to Hack】vulnhub narak
- npm ERR! fatal: early EOF npm ERR! fatal: index-pack failed
- 剑指 Offer 41. 数据流中的中位数
- Real time tracking of bug handling progress of the project through metersphere and dataease
- 【编译原理】语法分析
- Measures to support the development of advanced manufacturing industry in Futian District of Shenzhen in 2022
- Flume configuration 2 - ganglia for monitoring
猜你喜欢
随机推荐
【网络方向实训】-企业园区网络设计-【Had Done】
Zotero journal Automatic Matching Update Influencing Factors
The era of data security solutions
Freemaker template framework generates images
Sword finger offer 59 - ii Maximum value of the queue
mapbox-gl开发教程(十二):加载面图层数据
Nutch2.1在Windows平台上使用Eclipse debug 存储在MySQL的搭建过程
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
NLP - giza++ implements word alignment
Zotero journal automatic matching update influence factor
wangeditor富文本编辑器使用(详细)
雪花id,分布式唯一id
Common knowledge of ECS security settings
14,04 millions! Appel d'offres pour la mise à niveau de la base de données relationnelle et du système logiciel Middleware du Département des ressources humaines et sociales de la province du Sichuan!
画虎国手孟祥顺数字藏品限量发售,随赠虎年茅台
【Try to Hack】vulnhub narak
Linux安装MySQL8
如何设置 Pod 到指定节点运行
Flume theory
One hour to build a sample scenario sound network to release lingfalcon Internet of things cloud platform


![[notes] take notes again -- learn by doing Verilog HDL – 014](/img/92/ba794253f1588ff9ad87d2571a453e.png)





