time limit per test 2 seconds

memory limit per test 512 megabytes

input standard input

output standard output

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 r1 c1 r2 c2" means Oshino's placing barriers around a rectangle with two corners being (r1, c1) and (r2, c2) and sides parallel to squares sides. Similarly, "2 r1 c1 r2 c2" 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 r1 c1 r2 c2" means that Koyomi tries to walk from (r1, c1) to (r2, c2) without crossing barriers.

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

Input

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, r1, c1, r2, c2 (1 ≤ t ≤ 3, 1 ≤ r1, r2 ≤ n, 1 ≤ c1, c2 ≤ m) — the type and two coordinates of an action. Additionally, the following holds depending on the value of t:

  • If t = 1: 2 ≤ r1 ≤ r2 ≤ n - 1, 2 ≤ c1 ≤ c2 ≤ m - 1;
  • If t = 2: 2 ≤ r1 ≤ r2 ≤ n - 1, 2 ≤ c1 ≤ c2 ≤ m - 1, the specified group of barriers exist on the ground before the removal.
  • If t = 3: no extra restrictions.

Output

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.

Examples

input

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

output

No
Yes

input

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

output

No
Yes
No

Note

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

【翻译】给出n*m的方格纸,现在q个操作,1表示将给定矩形加上一圈墙,2表示删除给定矩形的墙(保证之前有墙),3表示询问两点是否能够到达。

题解:

   ①题目说,围墙不会重合,所以只要两个点在同一个墙内或者不在任何墙内,就可以通达。

   ②因此可以标记墙内所有点,给它们涂上一个颜色,然后维护一个差分,可以计算是否在墙内。

   ③颜色可以使用哈希值表示,对于查分使用二维树状数组维护。

#include<stdio.h>
#define base 4050
#define M 10000007
#define go(i,a,b) for(int i=a;i<=b;i++)
int n,m,q,x1,y1,x2,y2,t,c[2503][2503];
int Get_Hash()
{
long long a=0;
a=(a*base+x1)%M;a=(a*base+y1)%M;
a=(a*base+x2)%M;a=(a*base+y2)%M;
return (int)(a%M+M)%M;
}
void Add(int x,int y,int d)
{
int i=x;while(i<=n){
int j=y;while(j<=m)c[i][j]+=d,j+=j&-j;i+=i&-i;}
}
int Sum(int x,int y,int R=0)
{
int i=x;while(i){
int j=y;while(j)R+=c[i][j],j-=j&-j;i-=i&-i;}return R;
}
void Update(int val)
{
Add(x1,y1,val);
Add(x1,y2+1,-val);
Add(x2+1,y1,-val);
Add(x2+1,y2+1,val);
}
int main()
{
scanf("%d%d%d",&n,&m,&q);
while(q--&&scanf("%d%d%d%d%d",&t,&x1,&y1,&x2,&y2))
{
if(t==1)Update(+Get_Hash());
if(t==2)Update(-Get_Hash());
if(t==3)puts(Sum(x1,y1)==Sum(x2,y2)?"Yes":"No");
}
return 0;
}//Paul_Guderian

我听到无声的悲泣,回荡在心碎的恩赐之地,

闪烁的灯映着那忧伤的少年。——————汪峰《恩赐之地》

【CF Round 439 E. The Untended Antiquity】的更多相关文章

  1. 【CF Round 439 C. The Intriguing Obsession】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  2. 【CF Round 439 B. The Eternal Immortality】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  3. 【CF Round 439 A. The Artful Expedient】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  4. 【codeforces】【比赛题解】#869 CF Round #439 (Div.2)

    良心赛,虽然我迟了半小时233333. 比赛链接:#869. 呃,CF的比赛都是有背景的……上次是<哈利波特>,这次是<物语>…… [A]巧妙的替换 题意: Karen发现了石 ...

  5. 【CF Round 434 B. Which floor?】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  6. 【CF Round 434 A. k-rounding】

    Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...

  7. 【CF Round 429 B. Godsend】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. 【Codeforces Round #439 (Div. 2) C】The Intriguing Obsession

    [链接] 链接 [题意] 给你3种颜色的点. 每种颜色分别a,b,c个. 现在让你在这些点之间加边. 使得,同种颜色的点之间,要么不连通,要么连通,且最短路至少为3 边是无向边. 让你输出方案数 [题 ...

  9. 【Codeforces Round #439 (Div. 2) B】The Eternal Immortality

    [链接] 链接 [题意] 求b!/a!的最后一位数字 [题解] b-a>=20的话 a+1..b之间肯定有因子2和因子5 答案一定是0 否则暴力就好 [错的次数] 在这里输入错的次数 [反思] ...

随机推荐

  1. 文本处理工具-AWK

    awk简介 awk功能与sed相似,都是用来进行文本处理的.awk可以自动地搜索输入文件,并把每一个输入行切分成字段.许多工作都是自动完成的,例如读取每个输入行.字段分割. awk工作原理 awk一次 ...

  2. centOS初了解--***安装node

    在***买了一个VPS,用了差不多一年了,除了做FQ使用之外,同时也下载了一个node,用了express搭建了一个服务,同时我在博客园有博客,我也懒得转来转去了,直接做了一个重定向,跳转到了博客园. ...

  3. pywinauto 的使用

    要用python实现Windows窗口程序的自动化操作,可以用ctypes调用windowsapi来实现,还可以用pywin32+pywinauto来实现,后者是别人造的轮子. pywinauto首页 ...

  4. HTML+CSS : H5+CSS3

    HTML5语义化标签: header nav(导航) article section(章节) aside(侧边栏) footer------------------------------------ ...

  5. PAT (Basic Level) Practice 1004 成绩排名

    个人练习 读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. 输入格式:每个测试输入包含1个测试用例,格式为\ 第1行:正整数n 第2行:第1个学生的姓名 学号 成绩 第3行 ...

  6. [Codeforces976E]Well played!(贪心)

    [不稳定的传送门] Solution 首先可以证明,hp翻倍的操作一定是在同一个生物上最优 Code #include <cstdio> #include <algorithm> ...

  7. 全方位认识HDMI接口技术

    HDMI接口并不是一个开放的标准.制造商必须向HDMI标准制定协会支付版税,来换取一个生产许可证.不过这个版税可不便宜,每年要交纳15000美元的许可费,并且更黑的是每生产一个HDMI接口就要支付0. ...

  8. 抽象类的作用之一:sdk 传递你需要的参数

    抽象类可以干什么?抽象类可以让别人必须做一件事情,比如实现一个方法. 那它有什么作用呢? 我开始也不知道啊,后来慢慢的知道了,在开发中,我知道了它是干什么的,怎么用的.比如你要写一个sdk给别人用.但 ...

  9. web.py上传文件并解压

    有个需求是从php端上传zip文件到python端并且解压到指定目录,以下是解决方法 1.python端,使用的web.py def POST(self): post_data = web.input ...

  10. 关于 Inno Setup 报木马的问题处理

    用 Inno Setup 生成的安装包总是报木马,尝试了N次之后发现,把 Compression=lzma 改为 Compression=zip 就不会再报了,可能lzma的压缩算法导致delphi的 ...