DMOPC '17 Contest 1 P1 - Fujō NekoView as PDF
Saki is walking around the school fields when she notices that something might be stalking her. As such, she stops at locations on the field, with the being and takes a look directly in all 4 cardinal directions (north, south, east, and west) to see if she can locate these mysterious beings. Saki's vision is quite good, so even if the being is far away, as long as she's looking in the right direction, she is able to see it. (The top left corner is and the bottom right corner is .) Can you help Saki figure out if she's being stalked?
For all subtasks,
Subtask 1 [20%]
Subtask 2 [80%]
The first line will contain 2 space-separated integers, and , the number of rows and columns her school field has.
The next lines will each have characters, with a
X representing a mysterious being, and an
. representing flat land.
The next line will have an integer, .
The next lines will have two integers, and , her position on the field for the location.
The output should have lines, either
Y if she can see one of the mysterious beings, or
Note that fast input/output may be necessary.
4 4 X... .... .... ..X. 3 2 3 4 4 1 1
N Y Y
Explanation for Sample Output
S denote Saki's position. The first query looks like this:
X... .... .S.. ..X.
For the second query, the grid looks like the following:
X... .... .... ..XS
For the third query, the grid looks like this:
S... .... .... ..X.
Note that even though Saki is on the same square as a mysterious being, she can still see it.