302699: CF524E. Rooks and Rectangles

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Rooks and Rectangles

题意翻译

波雷卡普有一个n×m大小的棋盘,上面有k个车。他又放了q个矩形在上面。每一个矩形要受到保护。矩形受到保护的意思是对于该矩形内部所有的格子能够被这个矩形内的某个车攻击到或者被占据,和矩形外面的车无关,即矩形外面的车不能攻击到矩形里面。车的位置是固定的。 样例解释:对于最后一个矩形,用红色框框表示的,因为(1,2)不能被某个车攻击到,所以是NO。 ### 【输入格式】 单组测试数据。 第一行有4个整数 n, m, k 和q (1≤n,m≤100000, 1≤k,q≤200000),表示棋盘大小,棋盘上车的数目,放置矩形的数目。 棋盘的列是从左到右按照1到n编号,行是从下到上按照1到m编号。 接下来k行每一行有两个整数x y(1≤x≤n,1≤y≤m),表示车的位置。输入保证所有车的位置是不一样的。 接下来q行每一行有四个整数x1 y1 x2 y2(1≤x1≤x2≤n, 1≤y1≤y2≤m)。 表示符合x1≤x≤x2, y1≤y≤y2的格子在该矩形内。 ### 【输出格式】 对于每一个矩形,如果他是受保护的输出YES,否则输出NO。

题目描述

Polycarpus has a chessboard of size $ n×m $ , where $ k $ rooks are placed. Polycarpus hasn't yet invented the rules of the game he will play. However, he has already allocated $ q $ 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 $ n $ , $ m $ , $ k $ and $ q $ ( $ 1<=n,m<=100000 $ , $ 1<=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 $ 1 $ to $ n $ horizontally and from $ 1 $ to $ m $ vertically. Next $ k $ lines contain pairs of integers " $ x $ $ y $ ", describing the positions of the rooks ( $ 1<=x<=n $ , $ 1<=y<=m $ ). It is guaranteed that all the rooks are in distinct squares. Next $ q $ lines describe the strategically important areas as groups of four integers " $ x_{1} $ $ y_{1} $ $ x_{2} $ $ y_{2} $ " ( $ 1<=x_{1}<=x_{2}<=n $ , $ 1<=y_{1}<=y_{2}<=m $ ). The corresponding rectangle area consists of cells $ (x,y) $ , for which $ x_{1}<=x<=x_{2} $ , $ y_{1}<=y<=y_{2} $ . Strategically important areas can intersect of coincide.

输出格式


Print $ q $ 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: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF524E/c58f8346c9387e68fa79695b77d51d76a2899f31.png) For the last area the answer is "NO", because cell $ (1,2) $ cannot be hit by a rook.

Input

题意翻译

波雷卡普有一个n×m大小的棋盘,上面有k个车。他又放了q个矩形在上面。每一个矩形要受到保护。矩形受到保护的意思是对于该矩形内部所有的格子能够被这个矩形内的某个车攻击到或者被占据,和矩形外面的车无关,即矩形外面的车不能攻击到矩形里面。车的位置是固定的。 样例解释:对于最后一个矩形,用红色框框表示的,因为(1,2)不能被某个车攻击到,所以是NO。 ### 【输入格式】 单组测试数据。 第一行有4个整数 n, m, k 和q (1≤n,m≤100000, 1≤k,q≤200000),表示棋盘大小,棋盘上车的数目,放置矩形的数目。 棋盘的列是从左到右按照1到n编号,行是从下到上按照1到m编号。 接下来k行每一行有两个整数x y(1≤x≤n,1≤y≤m),表示车的位置。输入保证所有车的位置是不一样的。 接下来q行每一行有四个整数x1 y1 x2 y2(1≤x1≤x2≤n, 1≤y1≤y2≤m)。 表示符合x1≤x≤x2, y1≤y≤y2的格子在该矩形内。 ### 【输出格式】 对于每一个矩形,如果他是受保护的输出YES,否则输出NO。

加入题单

上一题 下一题 算法标签: