Problem N
Dacey the Dice
Dacey the Dice is lost in the twisted forest and needs help to find a way back home. Dacey the Dice moves by rolling over from one side to the next along dark and petrifying pathways. Dacey’s goal is to make a safe return to Dacey’s Home Sweet Home, which is a safeguarded by a magnetic door.
The twisted forest is laid out as an
Dacey’s Home Sweet Home is underground and is located at one
of the
Some of the
Dacey the Dice can only move by rolling over, which changes
both Dacey’s position and orientation. For example, if Dacey
has
Your task is to determine whether Dacey can reach the comfort of the inside of Dacey’s Home Sweet Home or not.
Input Format
The first line contains a single integer
-
. – Normal location
-
* – Wicked gigantic magnet
-
S – Dacey’s initial location
-
H – Dacey’s Home Sweet Home
There will be exactly one cell for Dacey’s initial location, and exactly one cell for Dacey’s Home Sweet Home.
Output Format
For each test case, output a single line with “Yes” if Dacey can successfully can get inside Dacey’s Home Sweet Home, or “No” otherwise.
Sample Input 1 | Sample Output 1 |
---|---|
5 2 *. HS 2 *. SH 2 S. .H 3 S.. ... ..H 3 S.. *** ..H |
Yes No No Yes No |