CF869E The Untended Antiquity

题目描述

\(\text{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 \times 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 \times 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.

输入输出格式

输入格式:

The first line of input contains three space-separated integers \(n\) , \(m\) and \(q\) ( \(1<=n,m<=2500\) , \(1<=q<=100000\) ) — the number of rows and columns in the grid, and the total number of Oshino and Koyomi's actions, respectively.

The following q 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 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.

输出格式:

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.


这题有几个要注意的条件:围墙不重叠不交叉不堵边界

可以对一个围墙里面的矩形进行染色。

查询看颜色是否一样。

具体来说,拿二维树状数组维护单点问区间改,差分一下

拿了随机数长整型自动取模wa,模大质数wa,听说不能随机。。

然后试了试,维护异或和就过了

注意维护异或和差分的写法。


Code:

#include <cstdio>
#include <cstdlib>
#include <ctime>
#define ll long long
const int N=2505;
int n,m,q;
ll s[N][N],tag[N][N];
void add(int x,int y,ll d)
{for(int i=x;i<=n;i+=i&-i)for(int j=y;j<=m;j+=j&-j)s[i][j]^=d;
}
ll query(int x,int y)
{ll sum=0;for(int i=x;i;i-=i&-i)for(int j=y;j;j-=j&-j)sum^=s[i][j];return sum;
}
int main()
{srand(19260817);scanf("%d%d%d",&n,&m,&q);for(int r1,c1,r2,c2,op,i=1;i<=q;i++){scanf("%d%d%d%d%d",&op,&r1,&c1,&r2,&c2);if(op==1){tag[r1][c1]=rand()*rand();add(r1,c1,tag[r1][c1]);add(r2+1,c2+1,tag[r1][c1]);add(r1,c2+1,tag[r1][c1]);add(r2+1,c1,tag[r1][c1]);}else if(op==2){add(r1,c1,tag[r1][c1]);add(r2+1,c2+1,tag[r1][c1]);add(r1,c2+1,tag[r1][c1]);add(r2+1,c1,tag[r1][c1]);}else{if(query(r1,c1)==query(r2,c2)) puts("Yes");else puts("No");}}return 0;
}

2018.10.11

转载于:https://www.cnblogs.com/butterflydew/p/9774855.html

CF869E The Untended Antiquity 解题报告相关推荐

  1. [CF869E]The Untended Antiquity

    The Untended Antiquity 题解 好水的题呀 由于没有矩形相交,任意两个矩形只存在包含与相离两种关系,由于要求的是两个点是否在同一矩阵中,我们可以对其进行染色,比较两点是否被染成同一 ...

  2. CF869E The Untended Antiquity(二维数状数组+差分+hash)

    考虑什么情况会不可达,当覆盖两点的最小矩形不同时,一定不可达.因此我们需要快速的知道覆盖一个点的最小矩形是哪个.我们考虑每次把一个矩形染色,那么复杂度是不可接受的.联想到我们一维做区间加法,单点查询时 ...

  3. uscao 线段树成段更新操作及Lazy思想(POJ3468解题报告)

    线段树成段更新操作及Lazy思想(POJ3468解题报告) 标签: treequerybuildn2cstruct 2011-11-03 20:37 5756人阅读 评论(0) 收藏 举报  分类: ...

  4. 解题报告(十八)数论题目泛做(Codeforces 难度:2000 ~ 3000 + )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量的题解和代码,题目难度不一 ...

  5. 【解题报告系列】超高质量题单 + 题解(ACM / OI)超高质量题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我新写的超高质量的题解和代码,题目难度不 ...

  6. 解题报告(三)多项式求值与插值(拉格朗日插值)(ACM / OI)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量的题解和代码,题目难度不一 ...

  7. 解题报告(十三)中国剩余定理(ACM / OI)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量的题解和代码,题目难度不一 ...

  8. 解题报告(四)生成函数(ACM/ OI)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量的题解和代码,题目难度不一 ...

  9. 解题报告(八) prufer 序列与 Cayley 公式(ACM / OI)超高质量题解

    繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量题解和代码,题目难度不一定按照题号排序,我会在每道题后面加上题目难度指数(1∼51 \sim 51∼5),以模板题难度 11 ...

最新文章

  1. 你绝对能懂的“机器学习”(一)
  2. 图像缩放算法_技术专栏|基于无人机LK光流算法的适用性及其优化方法探究
  3. python编程思维导图_用来梳理 Python 编程核心知识15张思维导图
  4. jquery创建添加append、prepend、appendTo、prependTo、after、insertAfter、before、insertBefore
  5. Codeforces Round 258(Div. 2)
  6. JSP毕业设计源码带论文和答辩、大作业、实例程序源码下载合集【10套】
  7. Qt界面开发(一)(各种控件以及图表)
  8. R包的安装以及安装失败的解决
  9. IRC(Internet Relay Chat)(因特网中继聊天)协议——RFC1459文档要点总结
  10. 大电流输出信号隔离转换模块
  11. 比较不错的资源搜索网站
  12. android x86 最新手机,Android-x86手机PC版的引导方法
  13. 生活就像个洋葱,一层一层剥开它,总有一层让你流泪
  14. 环保数采仪 有效解决数据采集、传输的问题
  15. 关于python中如何导入pygame模块(超详细)
  16. flash 怎么擦掉fpga_基于FPGA的flash板卡程序擦除与固化
  17. 关于某大型企业应用集成现状的思考
  18. 2004年美国二十五所最热门高校大盘点
  19. div包video在某些电脑或者浏览器上出现黑边
  20. 会计初级可以自己报名吗_初级会计考试可以自学吗?

热门文章

  1. 【基于python+Django的物品协同过滤音乐推荐系统-哔哩哔哩】 https://b23.tv/V2zN54R
  2. 4大私域流量体系(个人号、公众号、社群和小程序)全方面价值对比:私域流量,企业保命之本爆发之源!...
  3. shallot夏洛特
  4. 通达信接口大全:火线竞价器,最近很伙的指标!
  5. Studio5000和SE中如何使用替换功能
  6. 自写七言绝句三首,外加离职学习 ——彩虹国秘书长
  7. Excel收纳箱:VBA一键删除当前工作表的条件格式
  8. Mac也能玩3A大作?苹果这是要弄游戏本了吗?
  9. 什么牌子的蓝牙耳机耐用?类似airpods pro的降噪耳机推荐
  10. 八个典型的大数据应用案例