-18. Larger than Neighbors

I'm a slow walker, but I never walk backwards.

題目來源:judgegirl from ntu prof. pangfeng Liu

Task Description

Write a program to read the number of rows () and columns () of a two-dimensional integer array, then read the array elements row by row. Finally print the elements that are greater than all of its neighbors. Note that an element can have at most neighbors. If there are multiple such elements, print them in the order of row by row, column by column.

讀入一個 列的二維整數陣列,找到那些格子上的數字皆大於它的鄰近格子上的數字,鄰近只有限制在它的上下左右四格。如果有多個答案,從上而下、由左而右依序印出。

Limits

Both and are no more than .

Input Format

There are lines in the input. The first line has and . Each of the next lines has integers as a row in the matrix.

Output Format

There are lines in the output, where is the number of elements that are larger than its neighbors.

Sample Input

2 3
7 8 3
4 5 6

Sample Output

8
6

Submit

Login

Testdata Set

Download Testdata