AcWing 3708. 求矩阵的鞍点

输入样例:

复制代码
3 4
1 2 3 4
1 2 3 4
1 2 3 4

输出样例:

复制代码
1 4 4
2 4 4
3 4 4
cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n,m,a[N][N],x[N],y[N],flag=1;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int p=0;
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
			p=max(p,a[i][j]);
		}
		x[i]=p;
	}
	for(int i=1;i<=m;i++){
		int p=10;
		for(int j=1;j<=n;j++){
			cin>>a[j][i];
			p=min(p,a[j][i]);
		}
		y[i]=p;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]==x[i]&&a[i][j]==y[j]){
				cout<<i<<" "<<j<<" "<<a[i][j]<<endl;
				flag=0;	
			}
		}
	}
	if(flag) cout<<"NO";
	return 0;
}
相关推荐
电科_银尘21 小时前
【大模型算法与工程 15】手写Self-Attention:Q、K、V与缩放点积
算法
我不会插花弄玉1 天前
13.多路转接epoll【由浅入深-网络】
网络·c++·epoll
郝学胜-神的一滴1 天前
Effective STL 条款03:容器中的对象复制要廉价且正确
开发语言·数据结构·c++·算法·rpc·stl
秋天的怀念_David1 天前
算法一千零一夜 · 第三十三夜 · 跳表
java·程序人生·算法
西西弗Sisyphus1 天前
C++ explicit 关键字工程实践
开发语言·c++
Pniubi1 天前
力扣21合并两个有序链表
算法·leetcode·职场和发展
AIgorithmGEEK1 天前
std::unordered_map 与 std::unordered_set:接口、算法技巧与权衡 (速查)
c++·算法·哈希表·负载因子·桶·unordered_map·unordered_set
上海潭龙东海科技有限公司1 天前
智慧堆场动态模型三维实时孪生重构智能管控
大数据·网络·数据库·算法·重构
一拳一个呆瓜1 天前
【STL】头文件:<cmath>
c++·stl
草莓熊Lotso1 天前
【C++ 基于微服务的即时通讯系统】ElasticSearch 用户数据管理实现
linux·数据库·c++·elasticsearch·微服务·架构