Statistics

Problem Statement for "RainyRoad"

Problem Statement

Fox Ciel is going to take a path to meet her friends. The path is tiled with 1x1 square tiles. It is N tiles long and 2 tiles wide. If we imagine that the path is going from the left to the right, we can view it as a rectangle with 2 rows and N columns of tiles. The rows of the path are numbered 0 to 1 from top to bottom, and the columns of the path are numbered 0 to N-1 from left to right. Ciel starts at the tile in row 0, column 0. She has to reach the tile in row 0, column N-1.

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 String[] road. The j-th character of i-th element is 'W' if a tile at i-th row of j-th column is covered by water, and '.' otherwise.

Return the String "YES" if she can move to her destination without entering a tile which is filled with water. Otherwise, return "NO".

Definition

Class:
RainyRoad
Method:
isReachable
Parameters:
String[]
Returns:
String
Method signature:
String isReachable(String[] road)
(be sure your method is public)

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 '.'.

Examples

  1. {".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" "...."

  2. {".W.." ,"..W."}

    Returns: "YES"

  3. {".W..W.." ,"...WWW."}

    Returns: "NO"

  4. {".." ,"WW"}

    Returns: "YES"

  5. {".WWWW." ,"WWWWWW"}

    Returns: "NO"

  6. {".W.W.W." ,"W.W.W.W"}

    Returns: "YES"

  7. {".............................................W." ,".............................................W."}

    Returns: "NO"

  8. {"..", "W."}

    Returns: "YES"

  9. {"..", ".."}

    Returns: "YES"

  10. {"..", ".W"}

    Returns: "YES"

  11. {".W.", "WWW"}

    Returns: "NO"

  12. {".W.", "W.W"}

    Returns: "YES"

  13. {"...", "..."}

    Returns: "YES"

  14. {".W...", "W...."}

    Returns: "YES"

  15. {"...W......", "WW..W.W.W."}

    Returns: "YES"

  16. {"....WW.......W.", ".WW...WW......W"}

    Returns: "YES"

  17. {"..W.W....W..........", "WW..............W.WW"}

    Returns: "YES"

  18. {"........W......W...W.....", "W.WW........WW........W.."}

    Returns: "YES"

  19. {"..................................................", "W................................................."}

    Returns: "YES"

  20. {"..................................................", ".WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}

    Returns: "YES"

  21. {".WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW.", "W................................................W"}

    Returns: "YES"

  22. {".WWWWW.", "W.....W"}

    Returns: "YES"

  23. {"..WW.WW.WWW.WWWWWWWWW.W.W.", "WW..W..W...W.........W.W.W"}

    Returns: "YES"

  24. {".WWWWW.WWWWW.WWWW.WW.WWWWWW..WWWWWWWWWWWWWWW.", "......W.....W....W..W......WW................"}

    Returns: "YES"

  25. {".W.....", "......W"}

    Returns: "YES"

  26. {".WWW.W....W...........W...", "...............W........WW"}

    Returns: "YES"

  27. {"............W..W........W...........WW.......", "......W..........W.....W.................W..."}

    Returns: "YES"

  28. {".WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW.", ".WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}

    Returns: "NO"

  29. {"...WW...W.WWW.WWWWWW.W..WW.WWWW.......WWWW.WWW..W.", "W..WW...W.WWW.WWWWWW.W..WW.WWWW.......WWWW.WWW..WW"}

    Returns: "NO"

  30. {".W.W..W.W..W.WW...W..W.WW..W.W..WW..W.............", "WW...W.........W.W.WWW.W.WW.W..W......W..WW.WWWW.W"}

    Returns: "NO"

  31. {".W..WWW.W..W.WWW......W.W......W..W.W.WWW.WW.WWW..", ".W..WWW.W..W.WWW......W.W......W..W.W.WWW.WW.WWW.."}

    Returns: "NO"

  32. {"..W.W.WW..W.W.WW..WWWWWW.WW....W....W........W....", ".WWW.W..W..W....W...W.WWW..WW.W.WWWW..WW.......WW."}

    Returns: "NO"

  33. {"..W..W.", "WW.WW.W"}

    Returns: "YES"

  34. {".WWWWW.WWWWWWWWWWWWWWW..W.", "....W.W.....W..WW...W.WW.."}

    Returns: "NO"

  35. {".WWWWWWWWWWWWWWW.WW.W.WWWW.W..W.W.W.WWWWWWWW.", "....W.....WWWW..W..WWWWW.WW.WW.WWW.WW.....W.W"}

    Returns: "NO"

  36. {"....WW.", "....WWW"}

    Returns: "NO"

  37. {".WWW...WW.W.W.W.WW....WWW.", "W.W....WW.WWW...W...W.W.WW"}

    Returns: "NO"

  38. {".WWW..W....WWWW..W.WWWW.WWWW....W..WW.WW..W..", "WWWW...W..W..W.WW..W.WW.WWW..W...W..W.WW...W."}

    Returns: "NO"

  39. {".W.W.W.", "WWWW.WW"}

    Returns: "NO"

  40. {".W.W.WWWWWWWWW.WWW.WWWWW..", "WW.W.W.WWWWW.W.WWW.WWW.WW."}

    Returns: "NO"

  41. {".W.WW.WWWWWWW.WWWWWWW.W.WWWWWWWWW.W..WWWWWWW.", ".WWWWWW.WWWWW.W..WWWWWW.WWWWWWWWW.W.WWWWWWWW."}

    Returns: "NO"

  42. {".WWWWW.", "WWWWWW."}

    Returns: "NO"

  43. {".WWWWWWWWWWWWWWWWWWWWWWWW.", "WWWWWWWWWWWWWWWWWWWWWWWWW."}

    Returns: "NO"

  44. {".WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW.", "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW."}

    Returns: "NO"

  45. {".W............................................." ,".W............................................."}

    Returns: "NO"

  46. {".W..", "..W." }

    Returns: "YES"

  47. {".W.W.W.", "W.W.W.W" }

    Returns: "YES"

  48. {".W..", "...." }

    Returns: "YES"

  49. {".W..", ".W.." }

    Returns: "NO"

  50. {".W.", ".W." }

    Returns: "NO"

  51. {"..W.", ".W.." }

    Returns: "YES"

  52. {"...", ".W." }

    Returns: "YES"

  53. {".WW.", "..W." }

    Returns: "NO"

  54. {".W..W..", "...WWW." }

    Returns: "NO"

  55. {"...W.", "...W." }

    Returns: "NO"

  56. {".............................................W.", ".............................................W." }

    Returns: "NO"

  57. {".W.", "W.W" }

    Returns: "YES"

  58. {"...........................................W...", "...........................................W..." }

    Returns: "NO"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: