CF524E.Rooks and Rectangles

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarpus has a chessboard of size n×mn×m , where kk rooks are placed. Polycarpus hasn't yet invented the rules of the game he will play. However, he has already allocated qq rectangular areas of special strategic importance on the board, they must be protected well. According to Polycarpus, a rectangular area of ​​the board is well protected if all its vacant squares can be beaten by the rooks that stand on this area. The rooks on the rest of the board do not affect the area's defense. The position of the rooks is fixed and cannot be changed. We remind you that the the rook beats the squares located on the same vertical or horizontal line with it, if there are no other pieces between the square and the rook. Help Polycarpus determine whether all strategically important areas are protected.

输入格式

The first line contains four integers nn , mm , kk and qq ( 1<=n,m<=1000001<=n,m<=100000 , 1<=k,q<=2000001<=k,q<=200000 ) — the sizes of the board, the number of rooks and the number of strategically important sites. We will consider that the cells of the board are numbered by integers from 11 to nn horizontally and from 11 to mm vertically. Next kk lines contain pairs of integers " xx yy ", describing the positions of the rooks ( 1<=x<=n1<=x<=n , 1<=y<=m1<=y<=m ). It is guaranteed that all the rooks are in distinct squares. Next qq lines describe the strategically important areas as groups of four integers " x1x_{1} y1y_{1} x2x_{2} y2y_{2} " ( 1<=x1<=x2<=n1<=x_{1}<=x_{2}<=n , 1<=y1<=y2<=m1<=y_{1}<=y_{2}<=m ). The corresponding rectangle area consists of cells (x,y)(x,y) , for which x1<=x<=x2x_{1}<=x<=x_{2} , y1<=y<=y2y_{1}<=y<=y_{2} . Strategically important areas can intersect of coincide.

输出格式

Print qq lines. For each strategically important site print "YES" if it is well defended and "NO" otherwise.

输入输出样例

  • 输入#1

    4 3 3 3
    1 1
    3 2
    2 3
    2 3 2 3
    2 1 3 3
    1 2 2 3
    

    输出#1

    YES
    YES
    NO
    

说明/提示

Picture to the sample: For the last area the answer is "NO", because cell (1,2)(1,2) cannot be hit by a rook.

首页