#P21. [Sleeping Cup #2] Sleeping Bear's Honey 1
[Sleeping Cup #2] Sleeping Bear's Honey 1
Person in Charge
Attention
This problem requires file I/O (honey1.in / honey1.out).
Problem Background
Sleeping Bear is an adorable little bear who becomes even cuter the more honey it eats. However, every time it goes to collect honey, it gets stung by bees all over its head. Today it wants to eat honey again, but it doesn't want to get stung, so it asks you to help design an escape route to avoid the bees' pursuit.
Problem Description
Given a positive integer , representing a map with characters B, X, R, and L indicating:
B: Sleeping Bear's position (with bees right behind it by default);X: Impassable terrain;R: Passable road;L: Lake location (only by jumping into the lake can Sleeping Bear avoid bee stings).
Help Sleeping Bear find a path to the lakeside (it can move one cell up, down, left, or right each turn). Output Yes if such a path exists, otherwise output No.
Input Format
This problem contains multiple test cases.
The first line contains an integer , indicating the number of test cases.
For each test case:
- The first line contains an integer , representing the size of the map;
- The next lines each contain characters, describing the map's layout.
Output Format
For each test case, output one line with either Yes or No, indicating whether Sleeping Bear can escape the bees.
Sample
1
5
XXRRR
XRRRR
XXXXL
XXBRR
XXRRR
Yes
2
5
XXRRR
XRRRX
XXXXL
XXBRX
XXRRR
4
RRRR
XLXX
BXLR
RRLX
No
Yes
Sample 1 Explanation
Character G marks one possible escape route for Sleeping Bear:
XXRRR
XRRRR
XXXXL
XXBRG
XXGGG
Data Range
- For of cases: ,
- For of cases: ,
- The map is guaranteed to contain only
B,X,R, andLcharacters, with exactly oneB. - No guarantees are made about the number of
Ls!
Official Solution
相关
在下列比赛中: