RainyRoad
SRM 525 · 2011-05-25 · by ir5
Problem Statement
In each step, Ciel can move to an adjacent tile. Two tiles are adjacent if they share at least one point (a side or a corner).
Because it rained yesterday, some tiles are covered by puddles of water. Ciel will not step on these tiles. You are given a
Return the
Notes
- The constraints guarantee that the starting tile and the destination tile are never covered by water.
Constraints
- road will contain exactly 2 elements.
- Each elements of road will contain between 2 and 50 characters, inclusive.
- All elements of road will contain the same number of characters.
- Each character of road will be either '.' or 'W'.
- The first character and the last character of 0-th element of road will be '.'.
{".W.."
,"...."}
Returns: "YES"
One of the possible ways is as follows. Here, 'F' is the tile occupied by Fox Ciel. "FW.." "...." ".W.." "F..." ".W.." ".F.." ".W.." "..F." ".W.F" "...."
{".W.."
,"..W."}
Returns: "YES"
{".W..W.."
,"...WWW."}
Returns: "NO"
{".."
,"WW"}
Returns: "YES"
{".WWWW."
,"WWWWWW"}
Returns: "NO"
Submissions are judged against all 58 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RainyRoad with a public method string isReachable(vector<string> road) · 58 test cases · 2 s / 256 MB per case