#C8910. Maximum Color Codes in a Grid
Maximum Color Codes in a Grid
Maximum Color Codes in a Grid
You are given an N×N grid where each cell contains an integer representing a color code. Your task is to calculate two arrays:
- The first array contains the maximum color code from each row.
- The second array contains the maximum color code from each column.
For an input grid \(G\) where \(G_{ij}\) denotes the color code in the \(i^{th}\) row and \(j^{th}\) column, you must compute:
[ \text{row_max}[i] = \max_{1 \leq j \leq N} G_{ij} \quad \text{for} \quad 1 \leq i \leq N, ]
[ \text{col_max}[j] = \max_{1 \leq i \leq N} G_{ij} \quad \text{for} \quad 1 \leq j \leq N. ]
Print the row maximums on one line and the column maximums on the next, with each number separated by a single space.
inputFormat
The first line contains an integer N
representing the dimension of the grid. Each of the next N
lines contains N
integers separated by spaces, representing the grid's rows.
outputFormat
Output consists of two lines. The first line should contain the maximum values of each row (space-separated). The second line should contain the maximum values of each column (space-separated).
## sample3
5 1 2
3 9 4
7 6 8
5 9 8
7 9 8
</p>