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代码整合
随机推荐
- Spring笔记1
Spring Spring特点 1. 方便解耦,简化开发 通过Spring提供的IoC容器,我们可以将对象之间的依赖关系交由Spring进行控制,避免硬编码所造成的过度程序耦合.有了Spring,用户 ...
- (数据科学学习手札10)系统聚类实战(基于R)
上一篇我们较为系统地介绍了Python与R在系统聚类上的方法和不同,明白人都能看出来用R进行系统聚类比Python要方便不少,但是光介绍方法是没用的,要经过实战来强化学习的过程,本文就基于R对2016 ...
- LEAVE TO LIST-PROCESSING
LEAVE SCREEN 現在の画面の処理を中止し.次の画面を呼び出す - LEAVE TO SCREEN 現在の画面の処理を中止し.動的に定義された次の画面を呼び出す - LEAVE [PROGRA ...
- java 单例模式(singleton)
概念: 保证一个类仅有一个实例,并提供一个访问它的全局访问点. 要点: 1.某个类只有一个实例. 2.它必须自行创建这个示例. 3.必须自行向整个系统提供这个示例. 实现: 1.拥有一个私有的构造器. ...
- Spark Streaming实时处理应用
1 框架一览 事件处理的架构图如下所示. 2 优化总结 当我们第一次部署整个方案时,kafka和flume组件都执行得非常好,但是spark streaming应用需要花费4-8分钟来处理单个 ...
- C#的委托Delegate
一.委托基础 1.什么是委托 委托(Delegate) 是存有对某个方法的引用的一种引用类型变量,用关键字delegate申明,实现相同返回值和参数的函数的动态调用,提供了对方法的抽象. 委托(Del ...
- Yarn 调度器Scheduler详解
理想情况下,我们应用对Yarn资源的请求应该立刻得到满足,但现实情况资源往往是有限的,特别是在一个很繁忙的集群,一个应用资源的请求经常需要等待一段时间才能的到相应的资源.在Yarn中,负责给应用分配资 ...
- 封装一个ExcelHelper,方便将Excel直接转成Datatable对象
public class ExcelHelper { /// <summary> /// Excel转换成DataTable /// </summary> /// <pa ...
- Mac下用tomcat搭建下载服务器
1.下载tomcat 去官方网址: http://tomcat.apache.org/ 下载最新版 2.下载解压后,自己可以随便放在哪个文件夹下,自己记得路径即可.比如Users/你的用户名/Docu ...
- 「日常训练」 Soldier and Number Game (CFR304D2D)
题意 (Codeforces 546D) 给定一个数x=a!b!" role="presentation">x=a!b!x=a!b!的形式,问其中有几个质因数. 分 ...