Treasures in a map (1)

Write a program that, given a map with treasures and obstacles, indicates if is possible or not to arrive to any treasure from a given initial position. The allowed movements are horizontal or vertical, but not diagonal. If it is necessary, passing over the treasures is allowed.

Input

Input starts with the number of rows nn and the number of columns mm of the map. nn rows follow with mm characters each one. A dot indicates an empty position, a ’X’ indicates an obstacle, and a ’t’ indicates a treasure. Finally, a pair of numbers rr and cc indicates the initial row and column (both of them starting with 1) where your program must start to look for the treasures. You can suppose that n>0n > 0, that m>0m > 0, that rr will be between 1 and nn, that cc will be between 1 and mm, and that the initial position will be always in an empty position.

Output

Your program must print "1" or "0" depending on if it possible or not to arrive to any treasure.

Observation

The simplest way to solve this exercise does not use any queue.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T22:04:00.488Z

© Jutge.org, 2006–2026.
https://jutge.org