Author: | A. Klenin | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
The height map of some square country is represented with a matrix of N × N integers. Each integer reflects average height of the corresponding area. We will denote the height value at location (x, y) as h[x, y].
A location (x, y) is named depression if for all x′ = x−W… x+W, y′ = y−W… y+W location (x′, y′) is also inside of the map and h[x, y] ≤ h[x′,y′].
Your program must find coordinates of all depressions of the given height map.
Input file contains integers N W, followed by N × N integers — location heights, row-by-row.
Output file must contain an integer M — number of possible depressions, followed by M pairs of integers xi yi, where xi — the column of the i-th depression, yi — the row of the i-th depression. Numbering starts from 1.
Depressions must be ordered by y, then by x.
3 ≤ N ≤ 500
1 ≤ W
2 × W < N
1 ≤ h[x, y] ≤ 1000
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|