LCC '23 Contest 2 S1 - Aaron's Egg

View as PDF

Submit solution

Points: 5
Time limit: 1.5s
Memory limit: 64M

Author:
Problem type

Today, for the first time in his life, Aaron has decided to try frying an egg.

As an Amusingly Adorable Adolescent, Aaron thought that the best way to do so would be to use a 2\times N rectangular frying pan. In general, because of the monstrous chicken the egg came from, if any particular cell has some yolk on it, then it will flow to all cardinally adjacent cells on the frying pan (but not over the walls of the pan at its edges). Additionally, with such a large frying pan, some cells bulge out, making it impossible for the egg to flow onto them.

Aaron cracked his egg on the R-th row and the C-th column - can you figure out how many cells in the frying pan will have some eggs on them?

Constraints

1\le N\le 10^5

R\in\{1,2\}

1\le C\le N

Input Specification

The first line contains three integers N, R, and C.

Each of the next two lines contains N characters, which together form the grid. The j-th cell in i-th line describes the cell in the i-th row and j-th column. If it is an O, then the cell is not bulged; otherwise, if it is an #, then the cell is bulged. It is guaranteed that Aaron will crack his egg on a cell that isn't bulged.

Output Specification

One line with one integer, the number of cells on the frying pan that Aaron's egg will go onto.

Sample Input

5 1 3
O#O#O
OOO#O

Sample Output

5

Comments

There are no comments at the moment.