The 2021 China Collegiate Programming Contest (Harbin) J. Local Minimum

题目要求确定一个n*m矩阵中,有多少元素在其所在行或列中是最小值。给出矩阵大小n*m及各元素值,计算满足条件的元素数量。示例解释了有3个元素同时满足同行和同列最小的要求。
摘要由CSDN通过智能技术生成

题目链接:Problem - J - Codeforces

Given a matrix of size n×mn×m. Determine the number of entries who equals the minimum value among all other entries of the same row or column. Formally, determine the value of

∑i=1n∑j=1m[min{Mu,v|u=iorv=j}=Mi,j]∑i=1n∑j=1m[min{Mu,v|u=iorv=j}=Mi,j]

Note: [A]=1 if statement A is true, or [A]=0.

Input

The first line contains two integers n,m(1≤n,m≤1000), denoting the size of given matrix.

Following nn lines each contains mm integers Mi,j(1≤Mi,j≤106), denoting the given matrix.

Output

Output one line containing one integer, denoting the answer.

Example

input

3 3
1 5 9
4 3 7
2 6 2

output

3

Note

There are 3 entries M1,1=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值