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;
}
相关推荐
geovindu8 小时前
python:DecisionTree
开发语言·后端·python·算法
ShineWinsu8 小时前
对于Qt:事件的解析
c++·qt·面试·笔试·gui·客户端·事件
geovindu9 小时前
python: Decision Tree Regressor
开发语言·后端·python·算法·决策树
闻缺陷则喜何志丹10 小时前
【数论】P10136 [USACO24JAN] Cowlendar S|普及+
c++·数学·数论·洛谷
apcipot_rain10 小时前
某游戏公司C++游开实习 机试复盘
c++·游戏
AllData公司负责人11 小时前
实战二:AllData大模型与AI数据底座-数据传输平台-DBSyncer,搭建 Http 接口同步至 Doris,API 业务数据自动拉取入数仓
大数据·数据库·数据仓库·人工智能·算法·http·doris
武子康12 小时前
火系被选七成,就应该削弱吗?
人工智能·算法·机器学习
炸膛坦客13 小时前
单片机/C/C++八股:(三十七)指针数组 和 数组指针
c语言·开发语言·c++
夜不会漫长13 小时前
C++:C++11特性
开发语言·c++·算法