#P1683. Peach Blossom Island Entrance

    ID: 14968 Type: Default 1000ms 256MiB

Peach Blossom Island Entrance

Peach Blossom Island Entrance

On Peach Blossom Island, not everyone is welcome. The master of the island, Huang Yaoshi, dislikes dull-witted individuals like Guo Jing. Therefore, he paved the only entrance with square ceramic tiles. Some tiles are safe to step on (denoted by .), while others are deadly traps that emit lethal toxic gas (denoted by #). You are given the map of the tiles and the starting safe tile where you are teleported by Huang Rong, a trusted friend. Your task is to determine the maximum number of unique safe tiles you can traverse by moving only to adjacent tiles (up, down, left, right).

Note that you can step on a tile more than once, but it will only be counted once. Mathematically, if the set of safe tiles reachable from the starting tile is \( S \), your answer is \( |S| \). If you successfully cover all reachable safe tiles, the door to Peach Blossom Island will open automatically.

inputFormat

The first line contains two integers R and C which represent the number of rows and columns in the grid, respectively.

The next R lines each contain a string of length C consisting of characters . (safe tile) and # (unsafe tile).

The last line contains two integers representing the starting tile's row and column (0-indexed).

outputFormat

Output a single integer representing the maximum number of unique safe tiles that can be reached from the start tile.

sample

3 3
...
.#.
...
0 0
8