시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 15 | 5 | 5 | 45.455% |
Little Square has started jumping on trampolines from his school’s gym. In the gym there are R × C trampolines arranged in a rectangular grid with R rows and C columns. Each trampoline is either green or blue. There are exactly N green trampolines. Let (i, j) denote the trampoline in the ith row and jth column. We index the rows from 1 to R and the columns from 1 to C.
Little Square’s teacher has asked him to practice T gymnastics routines. The ith routine has the following rules:
Little Square wants to know, for each routine, if it is possible to accomplish his teacher’s request.
On the first line of the input you will find R, C and N. On the next N lines you will find the positions of the green trampolines. If a line contains integers a b then there is a green trampoline at position (a, b). On the next line you will find T. On the next T lines you will find the descriptions of the gymnastics routines. On the ith of these lines you will find xistart, yistart, xistop, yistop.
Output T lines. The ith line should contain Yes
if it possible to accomplish the ith routine, and No
if it is not.
4 5 2 2 2 3 4 3 2 1 4 5 1 2 1 4 2 3 4 4
Yes Yes No
The trampolines are placed like so:
In the first routine Little Square can go on the following route: (2, 1) → (2, 2) → (3, 2) → (3, 3) → (3, 4) → (4, 4) → (4, 5).
In the second routine Little Square can go on the following route: (1, 2) → (1, 3) → (1, 4).
The third routine cannot be accomplished. No route exists from (2, 3) to (4, 4) that respects Little Square’s teacher’s rules.
Contest > infO(1) Cup > infO(1) Cup 2020 2번