CF524E.Rooks and Rectangles

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

Polycarpus 有一个大小为 n×mn \times m 的棋盘,上面放置了 kk 个车(rook)。Polycarpus 尚未设计他将要进行的游戏规则,但他已在棋盘上预先划定了 qq 个具有特殊战略意义的矩形区域,这些区域必须得到良好保护。根据 Polycarpus 的定义,棋盘上的一个矩形区域被视为“受到良好保护”,当且仅当该区域内所有空格均能被位于该区域内部的车所攻击到。棋盘其余部分上的车对该区域的防御不产生任何影响。车的位置是固定的,不可移动。我们提醒您:车可以攻击与其位于同一行或同一列上的所有格子,但前提是该格子与车之间不存在其他棋子。请帮助 Polycarpus 判断所有战略重要区域是否均受到良好保护。

输入格式

The first line contains four integers n, m, k and q (1 ≤ n, m ≤ 100 000, 1 ≤ k, q ≤ 200 000) — 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.

第一行包含四个整数 nn、mm、kk 和 qq(1≤n,m≤100 0001 \leq n, m \leq 100\,000,1≤k,q≤200 0001 \leq k, q \leq 200\,000)——分别表示棋盘的尺寸、车的数量以及战略要地的数量。我们将棋盘的格子按水平方向编号为 11 到 nn,垂直方向编号为 11 到 mm。接下来的 kk 行每行包含一对整数 "xx yy",描述车的位置(1≤x≤n1 \leq x \leq n,1≤y≤m1 \leq y \leq m)。保证所有车均位于互不相同的格子中。接下来的 qq 行每行以四元组 "x1x_1 y1y_1 x2x_2 y2y_2" 描述一处战略要地(1≤x1≤x2≤n1 \leq x_1 \leq x_2 \leq n,1≤y1≤y2≤m1 \leq y_1 \leq y_2 \leq m)。对应矩形区域由所有满足 x1≤x≤x2x_1 \leq x \leq x_2 且 y1≤y≤y2y_1 \leq y \leq y_2 的格子 (x,y)(x, y) 构成。不同战略要地区域可以相交或重合。

输出格式

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

输出 q 行。对于每个战略要地,若其防御良好,则输出 "YES",否则输出 "NO"。

输入输出样例

  • 输入#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.

样例图片:
对于最后一个区域,答案为“NO”,因为车无法攻击到格子 (1, 2)(1,\,2)。

输入解题思路,AI测评打分。不知道怎么写?

首页