Hide and Seek

Hide and Seek is a children’s game in which players hide and one player
(the seeker) tries to find them. In one version of the game, the seeker
starts at a base, and to catch a player the seeker has to physically tag
them. The players hiding can make themselves safe by touching the base
before being tagged.

Alan is playing Hide and Seek, and he wants to know whether he should
run for the base or stay at his present location. Whenever Alan runs for
the base, the seeker (Kate) can see him and will also start running
towards the base. Alan and Kate run at the same speed, and if Kate
reaches the base before Alan, she will tag Alan before he touches the
base (in case of a tie, Kate still has time to tag Alan).

Input

The input starts with the number of test cases T ≤ 100. For each test
case, there is an integer N, 3 ≤ N ≤ 100, representing the size of the
map (N × N). The next N lines describe the map, where . is an empty
space, X is an obstacle, B is the base, A is Alan’s location, and K is
Kate’s location. Alan and Kate can only run in a horizontal or vertical
direction, not diagonally, and you may assume both can reach the base.

Output

For each test case, output “RUN” or “STAY” according to Alan’s best
strategy.

Problem information

Author: Anders Jonsson

Generation: 2026-01-25T22:05:53.633Z

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