CF869E.The Untended Antiquity

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Adieu l'ami.

Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around the abandoned Eikou Cram School building, Oshino's makeshift residence.

The space is represented by a rectangular grid of n × m cells, arranged into n rows and m columns. The c-th cell in the r-th row is denoted by (r, c).

Oshino places and removes barriers around rectangular areas of cells. Specifically, an action denoted by "1 _r_1 _c_1 _r_2 _c_2" means Oshino's placing barriers around a rectangle with two corners being (_r_1, _c_1) and (_r_2, _c_2) and sides parallel to squares sides. Similarly, "2 _r_1 _c_1 _r_2 _c_2" means Oshino's removing barriers around the rectangle. Oshino ensures that no barriers staying on the ground share any common points, nor do they intersect with boundaries of the n × m area.

Sometimes Koyomi tries to walk from one cell to another carefully without striding over barriers, in order to avoid damaging various items on the ground. "3 _r_1 _c_1 _r_2 _c_2" means that Koyomi tries to walk from (_r_1, _c_1) to (_r_2, _c_2) without crossing barriers.

And you're here to tell Koyomi the feasibility of each of his attempts.

再见,朋友。

小夜未正在帮助他的熟人冲野,照看废弃的荣光补习班大楼周围的空地——那里是冲野临时的住所。

该空地被表示为一个 n×mn \times m 的矩形网格,共 nn 行、mm 列。第 rr 行第 cc 列的格子记作 (r, c)(r,\,c)。

冲野会在某些矩形区域的四周放置或移除障碍物。具体而言,操作 “1 r1r_1 c1c_1 r2r_2 c2c_2” 表示冲野在以 (r1, c1)(r_1,\,c_1) 和 (r2, c2)(r_2,\,c_2) 为对角顶点、且边与网格线平行的矩形区域四周放置障碍物;类似地,“2 r1r_1 c1c_1 r2r_2 c2c_2” 表示冲野移除该矩形区域四周的障碍物。冲野保证:地面上所有存在的障碍物彼此之间不共享任何公共点,且也不与 n×mn \times m 区域的边界相交。

有时,小夜未会尝试在不跨越障碍物的前提下,从一个格子小心地走到另一个格子,以避免损坏地面的各种物品。“3 r1r_1 c1c_1 r2r_2 c2c_2” 表示小夜未试图从 (r1, c1)(r_1,\,c_1) 走到 (r2, c2)(r_2,\,c_2),且途中不穿越任何障碍物。

而你的任务,就是判断小夜未每一次尝试是否可行。

输入格式

The first line of input contains three space-separated integers n, m and q (1 ≤ n, m ≤ 2 500, 1 ≤ q ≤ 100 000) — the number of rows and columns in the grid, and the total number of Oshino and Koyomi's actions, respectively.

The following q lines each describes an action, containing five space-separated integers t, _r_1, _c_1, _r_2, _c_2 (1 ≤ t ≤ 3, 1 ≤ _r_1, _r_2 ≤ n, 1 ≤ _c_1, _c_2 ≤ m) — the type and two coordinates of an action. Additionally, the following holds depending on the value of t:

  • If t = 1: 2 ≤ _r_1 ≤ _r_2 ≤ n - 1, 2 ≤ _c_1 ≤ _c_2 ≤ m - 1;
  • If t = 2: 2 ≤ _r_1 ≤ _r_2 ≤ n - 1, 2 ≤ _c_1 ≤ _c_2 ≤ m - 1, the specified group of barriers exist on the ground before the removal.
  • If t = 3: no extra restrictions.

输入的第一行包含三个用空格分隔的整数 nn、mm 和 qq(1 ≤ n, m ≤ 2 5001 ≤ n, m ≤ 2\,500,1 ≤ q ≤ 100 0001 ≤ q ≤ 100\,000),分别表示网格的行数、列数以及“大野”与“小夜子”所执行的操作总数。

接下来的 qq 行每行描述一个操作,包含五个用空格分隔的整数 tt、r1r_1、c1c_1、r2r_2、c2c_2(1 ≤ t ≤ 31 ≤ t ≤ 3,1 ≤ r1, r2 ≤ n1 ≤ r_1, r_2 ≤ n,1 ≤ c1, c2 ≤ m1 ≤ c_1, c_2 ≤ m)—— 分别表示操作类型及该操作涉及的两个坐标。此外,根据 tt 的取值,还满足以下条件:

  • 若 t = 1t = 1:2 ≤ r1 ≤ r2 ≤ n − 12 ≤ r_1 ≤ r_2 ≤ n - 1,2 ≤ c1 ≤ c2 ≤ m − 12 ≤ c_1 ≤ c_2 ≤ m - 1;
  • 若 t = 2t = 2:2 ≤ r1 ≤ r2 ≤ n − 12 ≤ r_1 ≤ r_2 ≤ n - 1,2 ≤ c1 ≤ c2 ≤ m − 12 ≤ c_1 ≤ c_2 ≤ m - 1,且所指定的障碍物组在移除前确实存在于地面上;
  • 若 t = 3t = 3:无额外限制。

输出格式

For each of Koyomi's attempts (actions with t = 3), output one line — containing "Yes" (without quotes) if it's feasible, and "No" (without quotes) otherwise.

对于小夜美的每一次尝试(即参数 t=3t = 3 的操作),输出一行:若该尝试可行,则输出“Yes”(不含引号);否则输出“No”(不含引号)。

输入输出样例

  • 输入#1

    5 6 5
    1 2 2 4 5
    1 3 3 3 3
    3 4 4 1 1
    2 2 2 4 5
    3 1 1 4 4

    输出#1

    No
    Yes
  • 输入#2

    2500 2500 8
    1 549 1279 1263 2189
    1 303 795 1888 2432
    1 2227 622 2418 1161
    3 771 2492 1335 1433
    1 2017 2100 2408 2160
    3 48 60 798 729
    1 347 708 1868 792
    3 1940 2080 377 1546

    输出#2

    No
    Yes
    No

说明/提示

For the first example, the situations of Koyomi's actions are illustrated below.

对于第一个例子,小夜美的行动情况如下图所示。

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

首页