UF2015D - Bloxorz
Bloxorz, a flash game popularize by the Cool Math website, has a special place in the hearts of all middle schoolers. The game environment consists of a tiled grid on the plane. You as the player are a rectangular prism that is 1 tile in length and width but 2 tiles high. The goal of this game is to make a sequence of moves that will move you onto the end tile in the upright position. There are two 'states' your game character can be in: upright or laying down. Whenever you move in the upright state, your piece lays down in that direction. While you're laying down, if you move to a spot parallel to your piece you simply roll over and stay in the laying down state; otherwise, you move up just like you would expect.
In this problem you will be given a grid corresponding to an instance of the Bloxorz game. The grid has R rows and C columns and consists of characters. 'S' denotes the position you start on (in the upright position, of course) and 'G' is your goal. If any piece of your block is off the grid or touches a '#' tile it will fall off and the game must be restarted. '*' tiles can be moved on.
Input
The input will begin with a line containing a single positive integer, t, representing the number of test cases to process. Each test case will begin with two integers R (1 ≤ R ≤ 500) and C (1 ≤ C ≤ 500). Following that will be R lines, each line containing C characters which correspond to a row in the game grid.
Output
For each test case print "YES" if the game can be won and print "NO" otherwise. The output for each test case should be on its own line.
Example
Input: 2
3 8
S*****##
******G*
########
2 4
S*G*
#### Output: YES
NO
hide comments
Simes:
2023-04-26 19:52:08
Fun enough to be in classical, although I had to go find the actual game before I could understand the problem description.
|
|
nadstratosfer:
2018-09-08 19:00:44
Fun DFS, but CPP solution came out butt ugly and TL won't let an elegant Python one get AC. |
Added by: | Cormac |
Date: | 2015-02-19 |
Time limit: | 1s-4s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |
Resource: | UF High School Programming Contest 2015 |