시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 49 | 47 | 46 | 95.833% |
There is a legend about a magical park with N × N trees. The trees are positioned in a square grid with N rows (numbered from 1 to N from north to south) and N columns (numbered from 1 to N from west to east). The height (in metres) of each tree is an integer between 1 and N × N, inclusive. Magically, the height of all trees is unique.
Bunga is standing on the northmost point of the park and wants to count the number of visible trees for each column. Similarly, Lestari is standing on the westmost point of the park and wants to count the number of visible trees for each row. A tree X is visible if all other trees in front of the tree X are shorter than the tree X.
For example, let N = 3 and the height (in metres) of the trees are as follows.
6 1 8 7 5 3 2 9 4
Your task is to determine the numbers reported by Bunga and Lestari.
Input begins with a line containing an integer: N (1 ≤ N ≤ 10) representing the number of trees on each row and column. The next N lines each contains N integers representing the height (in metres) of the trees. The jth integer on the ith line is the height of the tree on the ith row and jth column between 1 to N × N, inclusive. It is guaranteed that all trees have different heights.
Output begins with a line containing N integers representing the number of trees visible by Bunga. The jth integer is the number of visible trees on the jth column. The next N lines each contains an integer representing the number of trees visible by Lestari. The integer on the ith line is the number of visible trees on the ith row.
3 6 1 8 7 5 3 2 9 4
2 3 1 2 1 2
5 22 1 10 2 17 13 12 20 6 7 14 19 3 15 24 4 11 18 25 9 5 23 21 8 16
1 4 3 4 2 1 2 3 4 2
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2020 A번
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2021 PB번