MetaOA #15
Find All Local Maximums
估计中等可在线判题
考点(AI 标注)模拟/实现
For a non-zero cell (i,j) with value v, examine the square region of radius v centered on it, ignoring the center itself and the four corners of the original full square, and comparing only cells inside the matrix. If no other value is ≥v, the cell is a local maximum. Output the coordinates in ascending order of row, then column. The original site's example includes invalid points, so this site recomputed it.
输入格式
This site's input scale: R C (1..30), followed by R lines of C non-negative integers each (0..10⁹). Indices start from 0, and the four corners are defined by the full square; you must not exclude the corners of the clipped region instead.
输出格式
The first line is the number t of local maxima; the next t lines give row col (starting from 0), in ascending order of row, then column. If there are no maxima, output only 0.
样例 1
输入:
5 5
3 0 0 0 0
0 0 1 0 0
0 0 2 0 0
0 0 0 0 0
0 3 0 0 3
输出:
1
0 0
样例 2
输入:
2 2
1 0
0 1
输出:
2
0 0
1 1
样例 3
输入:
1 1
0
输出:
0
样例说明
Example 1: only (0,0) is valid. Near (2,2), the non-corner cell (4,1) holds 3, which is greater than 2; the two 3s in the bottom row each fall within the other's comparison region, so neither is valid. Output the count 1 first, then 0 0.