codeforces—— 869E —— The Untended Antiquity
来源:互联网 发布:jsonarray解析json 编辑:程序博客网 时间:2024/06/07 23:45
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.
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.
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.
5 6 51 2 2 4 51 3 3 3 33 4 4 1 12 2 2 4 53 1 1 4 4
NoYes
2500 2500 81 549 1279 1263 21891 303 795 1888 24321 2227 622 2418 11613 771 2492 1335 14331 2017 2100 2408 21603 48 60 798 7291 347 708 1868 7923 1940 2080 377 1546
NoYesNo
For the first example, the situations of Koyomi's actions are illustrated below.
#include <cstring>#include <queue>#include <cstdio>#include <algorithm>#include <string>#include <map>#include <set>#include <vector>#include <iostream>#include <cmath>using namespace std;struct AP { int x1,x2,y1,y2; bool operator <(const AP &a)const { if(x1!=a.x1) return x1<a.x1; if(x2!=a.x2) return x2<a.x2; if(y1!=a.y1) return y1<a.y1; return y2<a.y2; } AP & operator = (const AP & a) { x1=a.x1; x2=a.x2; y1=a.y1; y2=a.y2; return *this; }};bool func1(int x,int y,AP pla) { if(x>=min(pla.x1,pla.x2)&&x<=max(pla.x1,pla.x2)) if(y>=min(pla.y1,pla.y2)&&y<=max(pla.y1,pla.y2)) return true; return false;}bool func2(AP val,AP pla) { int ans=0; ans+=func1(val.x1,val.y1,pla); ans+=func1(val.x2,val.y2,pla); if(ans==1) return false; return true;}int main() { int x,y,z; while(~scanf("%d%d%d",&x,&y,&z)) { int vju,x1,y1,x2,y2; set<AP>se1; while(z--) { AP t; scanf("%d%d%d%d%d",&vju,&t.x1,&t.y1,&t.x2,&t.y2); if(vju==1) se1.insert(t); if(vju==2) se1.erase(se1.find(t)); if(vju==3) { set<AP>::iterator it; for(it=se1.begin(); it!=se1.end(); it++) if(!func2(t,(*it))) { vju=0; break; } if(vju) printf("Yes\n"); else printf("No\n"); } } } return 0;}
- codeforces—— 869E —— The Untended Antiquity
- Codeforces 869 E. The Untended Antiquity 二维树状数组
- codeforces 869E The Untended Antiquity 二维BIT + hash
- [哈希+差分] Codeforces 869E. The Untended Antiquity
- CF869 E. The Untended Antiquity
- CF869 E. The Untended Antiquity
- Codeforces Round #439 E. The Untended Antiquity (树状数组+随机化)
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity
- CF 869E(The Untended Antiquity-Hash值维护连通性)
- CF #439 E The Untended Antiquity
- Codeforces Round #439 (Div. 2) E:The Untended Antiquity(Hash+二维树状数组)
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity (hash+数状数组)
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity(二维BIT)
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维树状数组 随机化
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity(Hash)
- Codeforces869E The Untended Antiquity
- 研究生如何找到一份数据挖掘的工作
- GTK实现:扫雷源代码(saolei.c)
- 设置环境变量
- J
- [JSOI2008]最大数maxnumber
- codeforces—— 869E —— The Untended Antiquity
- redis命令行基本操作
- centOS 关闭防火墙
- nyoj 358 取石子(五)(Fibonacci博弈)(博弈——找规律)
- Tensorflow实例:Inception-v3模型
- docker的内核依赖与简单构建
- esp8266(一)esp8266和电脑在同一局域网中传输数据
- java文件操作
- python--leetcode695. Max Area of Island