#P2472. [SCOI2007] 蜥蜴

    ID: 1484 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>模拟2007四川各省省选网络流最大流

[SCOI2007] 蜥蜴

Description

On an rr-row cc-column grid map, there are stone pillars of varying heights. The pillar at row ii, column jj has height hi,jh_{i,j}.

Some pillars have lizards standing on them. Your task is to let as many lizards as possible escape outside the boundary.

The distance between adjacent pillars in the same row or column is 11. Each lizard has a jump distance of dd, meaning it can jump to any pillar whose Euclidean distance is at most dd.

The pillars are unstable. Each time a lizard jumps, the height of the pillar it leaves decreases by 11 (if it still lands inside the map, the destination pillar’s height does not change).

If that pillar’s original height is 11, then after a lizard leaves, the pillar disappears, and no other lizard can land on it thereafter.

At any time, no two lizards may stand on the same pillar.

Input Format

The first line contains three integers r,c,dr, c, d, which are the map size and the maximum jump distance.

The next rr lines each contain cc numbers describing the initial state of the pillars: 00 means there is no pillar, otherwise it is the initial height hi,jh_{i,j}.

The next rr lines each contain cc characters describing lizard positions: L means a lizard, and . means no lizard.

Output Format

Output a single line containing one integer, which is the minimum total number of lizards that cannot escape.

5 8 2
00000000
02000000
00321100
02000000
00000000
........
........
..LLLL..
........
........

1

Hint

For 100%100\% of the testdata: 1r,c201 \le r, c \le 20, 1d41 \le d \le 4, 1h31 \le h \le 3.

Translated by ChatGPT 5