아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Fishing Contest

시간 제한2초메모리 제한512 MB

요약
각 격자점에서 물고기가 짧은 시간 동안만 나타날 때, 시작점에서 제한 시간 안에 이동하며 물고기를 잡을 수 있는 서로 다른 점의 최대 개수를 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, BFS, 그래프, 시뮬레이션
정답자
아직 제출이 없습니다

문제

In a fishing contest, the participants fish in a lake, represented as a 2D grid of dimension r×cr \times c. Each integer point in the grid contains fish.

At point (x,y)(x, y), fish first appear at second t_x,yt\_{x, y} and disappear just before time t_x,y+kt\_{x, y} + k 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 11 second.

Assume that you start at some position (x_0,y_0)(x\_0, y\_0) at second 11, and can catch fish until (and including) second ll. 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 rr, cc, kk and ll (1≤r,c≤1001 \le r, c \le 100, 1≤k≤51 \le k \le 5, 1≤l≤1051 \le l \le 10^5), 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 x_0x\_0 and y_0y\_0 (0≤r<x_00 \le r < x\_0, 0≤c<y_00 \le c < y\_0), your original position.
  • rr lines, the xx'th of which contains cc integers t_x,0,…,t_x,c−1t\_{x, 0}, \dots, t\_{x, c - 1} (each between 11 and ll, inclusive), the times at which fish appers on points in the xx'th row.

출력

Output the maximum number of points you could catch fish from.

예제3

  1. 예제 1

    입력
    2 2 1 10
    0 0
    1 4
    3 2
    
    예상 출력
    2
    
  2. 예제 2

    입력
    2 3 5 6
    1 1
    1 1 6
    1 2 2
    
    예상 출력
    5
    
  3. 예제 3

    입력
    2 3 5 7
    1 1
    1 1 6
    1 2 2
    
    예상 출력
    6