You are given an
Constraints
For all subtasks:
Each given blocked square is unique, and for all queries the squares
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line will contain
The next
The following
Output Specification
For each query, output one line containing YES
if it is possible to reach NO
otherwise.
Sample Input 1
5 5 11 1
2 2
4 2
3 2
2 3
5 2
3 1
1 5
3 5
2 5
4 5
4 4
1 1 5 5
Sample Output 1
YES
Explanation for Sample 1
The following is a diagram for the grid given in Sample 1 (.
marks open squares, while #
marks blocked squares):
....#
.##.#
##..#
.#.##
.#...
It can be shown that there is a path from
Sample Input 2
5 5 9 3
5 1
1 2
1 5
3 2
2 3
5 3
3 3
3 5
4 4
1 1 5 5
2 1 4 3
2 5 2 5
Sample Output 2
NO
YES
YES
Explanation for Sample 2
The following is a diagram for the grid given in Sample 2 (.
marks open squares, while #
marks blocked squares):
.#..#
..#..
.##.#
...#.
#.#..
Comments
What is the intended solution for this problem? I need hints.