## DMOPC '17 Contest 1 P1 - Fujō Neko

View as PDF

Points: 5 (partial)
Time limit: 3.0s
Memory limit: 64M

Author:
Problem type

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?

#### Input Specification

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 an X representing a mysterious being, and a . 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.

#### Output Specification

The output should have lines, either Y if she can see one of the mysterious beings, or N otherwise.

Note that fast input/output may be necessary.

#### Sample Input

4 4
X...
....
....
..X.
3
2 3
4 4
1 1

#### Sample Output

N
Y
Y

#### Explanation for Sample Output

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

• commented on Aug. 4, 2022, 4:58 a.m.

This is the first time I'm tring to use fast input/output and something isn't right

I keep geting indexing error but I don't know what I'm doing wrong

Anyone else have some better tutorial for usgin stdin and stdout ?! I tried the tutorial posted but something is wrong ... please help me out here....

• commented on April 21, 2022, 5:21 a.m.

Arg, is anyone able to help me here? I'm not sure how the subtasks work here, and I'm getting an IR error after the first case. Thanks in advance.... Joe

• commented on April 21, 2022, 6:51 p.m.

• commented on Jan. 10, 2020, 11:08 p.m.

How come when I use fast I/O I TLE.

• commented on Jan. 10, 2020, 11:14 p.m.

It TLEs because you're trying to mix your scan function with cin when you didn't sync cin with stdio.

As a rule of thumb, usually just including cin.tie(0), ios::sync_with_stdio(0) is fast enough for most applications :).

• commented on Nov. 4, 2017, 11:22 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Nov. 3, 2017, 7:49 p.m.

Please what's wrong in my code ? All my tests are correct but the autocorrection say that is wrong

• commented on Nov. 3, 2017, 8:21 p.m.

Take another look at the input specification:

The next lines will each have characters