CF869E The Untended Antiquity 解题报告
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
CF869E The Untended Antiquity 解题报告的更多相关文章
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity
E. The Untended Antiquity 题目链接http://codeforces.com/contest/869/problem/E 解题心得: 1.1,x1,y1,x2,y2 以(x1 ...
- CH Round #56 - 国庆节欢乐赛解题报告
最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...
- 二模13day1解题报告
二模13day1解题报告 T1.发射站(station) N个发射站,每个发射站有高度hi,发射信号强度vi,每个发射站的信号只会被左和右第一个比他高的收到.现在求收到信号最强的发射站. 我用了时间复 ...
- BZOJ 1051 最受欢迎的牛 解题报告
题目直接摆在这里! 1051: [HAOI2006]受欢迎的牛 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 4438 Solved: 2353[S ...
- 习题:codevs 2822 爱在心中 解题报告
这次的解题报告是有关tarjan算法的一道思维量比较大的题目(真的是原创文章,希望管理员不要再把文章移出首页). 这道题蒟蒻以前做过,但是今天由于要复习tarjan算法,于是就看到codevs分类强联 ...
- 习题:codevs 1035 火车停留解题报告
本蒟蒻又来写解题报告了.这次的题目是codevs 1035 火车停留. 题目大意就是给m个火车的到达时间.停留时间和车载货物的价值,车站有n个车道,而火车停留一次车站就会从车载货物价值中获得1%的利润 ...
- 习题: codevs 2492 上帝造题的七分钟2 解题报告
这道题是受到大犇MagHSK的启发我才得以想出来的,蒟蒻觉得自己的代码跟MagHSK大犇的代码完全比不上,所以这里蒟蒻就套用了MagHSK大犇的代码(大家可以关注下我的博客,友情链接就是大犇MagHS ...
- 习题:codevs 1519 过路费 解题报告
今天拿了这道题目练练手,感觉自己代码能力又增强了不少: 我的思路跟别人可能不一样. 首先我们很容易就能看出,我们需要的边就是最小生成树算法kruskal算法求出来的边,其余的边都可以删掉,于是就有了这 ...
- NOIP2016提高组解题报告
NOIP2016提高组解题报告 更正:NOIP day1 T2天天爱跑步 解题思路见代码. NOIP2016代码整合
随机推荐
- js 节点
var chils= s.childNodes; //得到s的全部子节点 var par=s.parentNode; //得到s的父节点 var ns=s.nextSbiling; //获得s的下 ...
- FireDAC内存表
procedure TForm1.FormCreate(Sender: TObject); Var i:integer; begin // i:=; self.FDMemTable1.FieldDef ...
- mybatis动态列名
mybatis动态列名 <select id="getUser" resultType="java.util.Map" parameterType=&qu ...
- HyperLedger Fabric 1.4 交易流程(6.3)
区块链最主要的特性之一是去中心化,没有了中心机构的集中处理,为了达成数据的一致性,就需要网络中全民参与管理,并以某种方法达成共识,所以区块链的交易流程也就是共识的过程. 在Fabric中, ...
- UVA 1593 Alignment of Code(紫书习题5-1 字符串流)
You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is ...
- python--基本类型之列表
Lest(列表): 定义和创建列表: 列表:是python以及其他语言中最常用的数据结构之一.python用 [] 来解析列表列表是可变的.--可以改变列表的内容可以用切片 a=['张三','李四', ...
- shell -- for、while用法
#数字段形式for i in {1..10}do echo $idone #详细列出(字符且项数不多)for File in 1 2 3 4 5do echo $Filedone #对存在的 ...
- 四大IO抽象类
四大IO抽象类 InputStream/OutputStream和Reader/writer类是所有IO流类的抽象父类,我们有必要简单了解一下这个四个抽象类的作用.然后,通过它们具体的子类熟悉相 ...
- "Cannot open source file "Wire.h" " in Arduino Development
0. Environment Windows 8 x64 Arduino 1.0.5 Visual studio 2012 Visual micro Arduino 1. Steps Add &quo ...
- C# 删除文件错误 access denied
使用以下代码正常删除整个文件夹内容时,报错如下: if (backupPathDir.Exists) { System.IO.DirectoryInfo di = new DirectoryInfo( ...