Fishing Contest
시간 제한2초메모리 제한512 MB
각 격자점에서 물고기가 짧은 시간 동안만 나타날 때, 시작점에서 제한 시간 안에 이동하며 물고기를 잡을 수 있는 서로 다른 점의 최대 개수를 구한다.
문제
In a fishing contest, the participants fish in a lake, represented as a 2D grid of dimension . Each integer point in the grid contains fish.
At point , fish first appear at second and disappear just before time seconds. Outside of this time, no fish can be caught at this position. It takes no time to catch all the fish at a point, and all points contain the same amount of fish. Furthermore, moving to the point immediately north, west, south or east from the point you are currently at takes exactly second.
Assume that you start at some position at second , and can catch fish until (and including) second . From how many points in the lake can you catch fish, if you travel optimally on the lake?
입력
The input consists of:
- one line with the integers , , and (, , ), the dimensions of the lake, the number of seconds fish stays at a point, and the number of seconds you can catch fish.
- one line with the integers and (, ), your original position.
- lines, the 'th of which contains integers (each between and , inclusive), the times at which fish appers on points in the 'th row.
출력
Output the maximum number of points you could catch fish from.