题目描述
Problem Description
In Saitama, there is an annual festival where the most beautiful float is awarded a prize. Saitama and his friends decided to participate after hearing about the prize money.
On their way to the festival venue, a group of men from the neighboring town got on the float to obstruct them. It seems that there are $a$ men on the right side and $b$ men on the left side of the float.
Saitama and his friends want to showcase a perfect float and need to shake off all the men before reaching the venue.
The possible movements of the float within a unit time are as follows:
- Turn 90 degrees to the left and move one square forward.
- Turn 90 degrees to the right and move one square forward.
- Move one square forward without changing direction.
The movement in 1. can shake off one person on the right side, and the movement in 2. can shake off one person on the left side.
However, they do not want to change direction more than necessary, so after performing the movement in 1. $a$ times, they will no longer perform the movement in 1., and after performing the movement in 2. $b$ times, they will no longer perform the movement in 2.
Saitama and his friends decided to plan their route using a map.
The map has a height of $h$ and a width of $w$, where passable places are represented by $'.'$ and impassable places are represented by $'#'$. The streets they pass through are divided into a grid, and the square at the $i$-th row and $j$-th column on the map is represented by $c(i,j)$.
Their current location is $c(2,2)$, and the venue is $c(h-1,w-1)$. It is guaranteed that both the current location and the venue are $'.'$.
The outermost part of the map is surrounded by $'#'$. The direction facing $c(1,1)$ to $c(1,w)$ is north, and Saitama and his friends are initially facing south.
Determine if Saitama and his friends can safely participate in the festival.
Input Format
The input is given from the standard input in the following format:
$a$ $b$ $h$ $w$ $c(1,1)c(1,2)\ …\ c(1,w)$ $c(2,1)c(2,2)\ …\ c(2,w)$ $:$ $c(h,1)c(h,2)\ …\ c(h,w)$
The first line contains the number of men on the right side $a$ and the number of men on the left side $b$. The second line contains the height $h$ and width $w$ of the map. The following $h$ lines each contain a string of length $w$. Each character $c(i,j)$ is either $'.'$ or $'#'$, where $'.'$ represents a passable location and $'#'$ represents an impassable location.
Output Format
Output "Yes" if Saitama and his friends can safely participate in the festival, otherwise output "No".
Sample Input and Output
Sample Input #1
3 3
7 7
#######
#.#..##
#..#..#
##...##
#..#..#
##..#.#
#######
Sample Output #1
Yes
Sample Input #2
4 3
5 7
#######
#.#..##
#...#.#
#.#...#
#######
Sample Output #2
No
Notes/Hints
Constraints
- $1 \leq a, b \leq 15$
- $3 \leq h, w \leq 15$
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分