#C2960. Find the Highest Peak in a Matrix

    ID: 46334 Type: Default 1000ms 256MiB

Find the Highest Peak in a Matrix

Find the Highest Peak in a Matrix

Given a 2D matrix of integers representing elevations, your task is to find the highest peak in the matrix. A cell in the matrix is considered a peak if its elevation is not lower than any of its 8 neighbors. In mathematical terms, a cell at position \((i, j)\) is a peak if for every neighbor at \((i+\delta_i, j+\delta_j)\) with \(\delta_i, \delta_j \in \{-1, 0, 1\}\) (excluding the cell itself), the following holds (provided the neighbor exists):

matrix[i][j]matrix[i+δi][j+δj]matrix[i][j] \ge matrix[i+\delta_i][j+\delta_j]

If there are multiple peaks with the same highest elevation, output the one that appears first in row-major order (i.e., top to bottom, left to right).

inputFormat

The first line of input contains two space-separated integers (r) and (c), the number of rows and columns respectively. This is followed by (r) lines, each containing (c) space-separated integers representing the elevation values of the matrix.

outputFormat

Output two space-separated integers representing the 0-indexed row and column of the highest peak.## sample

1 1
42
0 0