Loneliness

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem types

jsumabat is a student at Thornhill Secondary School. He only has 1 friend and that friend is RayZhang who also goes to the school. During their lunch break, Jsumabat is looking for his only friend in the cafeteria. Looking around, jsumabat realizes that some of his field of view is blocked by tables because he is very short. Given the layout of the cafeteria, determine is jsumabat can see his only friend if he were to look in the 4 cardinal directions.

Input Specification

The first line of input contains n (3 \le n \le 10000) representing the dimensions of the square shaped cafeteria.
The next n lines of input each contain n characters representing a row in the cafeteria. a . character represents empty space that jsumabat can see through. A | character represents a table that obscures his field of view. A j represents jsumabat's location and r represents the location of his only friend. It is guaranteed that there will be 1 occurrence of j and 1 occurrence of r. It is guaranteed that r will be directly in one of the 4 cardinal directions of j.

Output Specification

Print YES if jsumabat can see his only friend and ALL ALONE if he can not.

Sample Input

5
.r...
.|...
.....
.j...
..||.

Sample Output

ALL ALONE

Comments

There are no comments at the moment.