A9806 | Rooks and Rectangles
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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:  For the last area the answer is "NO", because cell $(1,2)$ cannot be hit by a rook.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted