UberOA #57
Regional Maximum Finder
估计中等可在线判题
考点(AI 标注)模拟/实现原地数组
For a non-zero cell (i,j), its value v also serves as a radius, and its region is [i−v,i+v]×[j−v,j+v] with the four original corner points removed and any out-of-bounds part ignored. A cell is a region maximum if its value equals the maximum over its region; tied maximums are all kept. Return all such cells in any order.
This site has made the standard input and output explicit.
输入格式
The first line contains n m, followed by n lines of m integers. On this site 1≤n,m≤100 and 0≤value≤10⁹.
输出格式
First output the number of cells k, then k pairs of 0-based row and column coordinates, in any order and without duplicates.
样例 1
输入:
3 3
3 0 1
2 0 0
0 0 0
输出:
2
0 0
0 2
样例 2
输入:
2 2
1 9
0 1
输出:
1
0 1
样例 3
输入:
2 2
2 2
2 2
输出:
4
0 0
0 1
1 0
1 1
样例说明
Example 1: only the 3 at (0,0) and the 1 at (0,2) qualify. Example 2: the 9 at (0,1) is the largest; both regions of the two 1s contain it, and it is not an original corner, so only (0,1) qualifies. Example 3: all four cells tie for the maximum, so output all of them, in any order.