#C5272. Find Lowest Point in a Grid
Find Lowest Point in a Grid
Find Lowest Point in a Grid
You are given a grid of integers with (n) rows and (m) columns, where each cell represents a height value. Your task is to find the coordinates (row and column) of the lowest point in the grid. The coordinates are 1-indexed. If there are multiple cells with the same minimum value, choose the cell that appears first in reading order (i.e. the one with the smallest row number, and if rows are equal, the smallest column number).
Mathematically, given the grid (A) where (A_{i,j}) denotes the height at row (i) and column (j), you need to find ((i,j)) such that: [ A_{i,j} = \min_{1 \leq i \leq n,\ 1 \leq j \leq m} A_{i,j} ] and if there are several solutions, choose the lexicographically smallest coordinate ((i,j)).
inputFormat
Input is read from standard input (stdin). The first line contains two integers (n) and (m) ((1 \le n, m \le 1000)), representing the number of rows and columns, respectively. This is followed by (n) lines, each containing (m) integers separated by a space, representing the grid.
outputFormat
Output to standard output (stdout) two integers separated by a space, representing the 1-indexed row and column of the lowest point in the grid.## sample
3 3
1 2 3
4 5 6
7 8 9
1 1