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 解题报告的更多相关文章

  1. 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 ...

  2. CH Round #56 - 国庆节欢乐赛解题报告

    最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...

  3. 二模13day1解题报告

    二模13day1解题报告 T1.发射站(station) N个发射站,每个发射站有高度hi,发射信号强度vi,每个发射站的信号只会被左和右第一个比他高的收到.现在求收到信号最强的发射站. 我用了时间复 ...

  4. BZOJ 1051 最受欢迎的牛 解题报告

    题目直接摆在这里! 1051: [HAOI2006]受欢迎的牛 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4438  Solved: 2353[S ...

  5. 习题:codevs 2822 爱在心中 解题报告

    这次的解题报告是有关tarjan算法的一道思维量比较大的题目(真的是原创文章,希望管理员不要再把文章移出首页). 这道题蒟蒻以前做过,但是今天由于要复习tarjan算法,于是就看到codevs分类强联 ...

  6. 习题:codevs 1035 火车停留解题报告

    本蒟蒻又来写解题报告了.这次的题目是codevs 1035 火车停留. 题目大意就是给m个火车的到达时间.停留时间和车载货物的价值,车站有n个车道,而火车停留一次车站就会从车载货物价值中获得1%的利润 ...

  7. 习题: codevs 2492 上帝造题的七分钟2 解题报告

    这道题是受到大犇MagHSK的启发我才得以想出来的,蒟蒻觉得自己的代码跟MagHSK大犇的代码完全比不上,所以这里蒟蒻就套用了MagHSK大犇的代码(大家可以关注下我的博客,友情链接就是大犇MagHS ...

  8. 习题:codevs 1519 过路费 解题报告

    今天拿了这道题目练练手,感觉自己代码能力又增强了不少: 我的思路跟别人可能不一样. 首先我们很容易就能看出,我们需要的边就是最小生成树算法kruskal算法求出来的边,其余的边都可以删掉,于是就有了这 ...

  9. NOIP2016提高组解题报告

    NOIP2016提高组解题报告 更正:NOIP day1 T2天天爱跑步 解题思路见代码. NOIP2016代码整合

随机推荐

  1. Mysqldump自定义导出n条记录

    很多时候DBA需要导出部分记录至开发.测试环境,因数据量需求较小,如果原库的记录多,且表数量也多,在用mysqldump命令导出时可以添加一个where参数,自定义导出n条记录,而不必全量导出. 示例 ...

  2. mysql帐号不允许从远程登陆

    默认情况下,mysql帐号不允许从远程登陆,只能在localhost登录.本文提供了二种方法设置mysql可以通过远程主机进行连接. 一.改表法 在localhost登入mysql后,更改 “mysq ...

  3. django的模型和基本的脚本命令

    python manage.py startproject project_name  创建一个django项目 python manage.py startapp app_name  创建一个app ...

  4. python 面向对象 (多态)

    什么是多态?多态就像是人有多种心情,场景不一样心情就会不一样. class Dog: def print_self(self): print('this is dog') class Hsq(Dog) ...

  5. Java+Selenium3自动化测试框架设计系列--href="javascript:void(0)"如何获得元素定位

    经过前面两篇文章的铺 垫,我们这篇介绍,webdriver如何处理,一个浏览器上多个窗口之间切换的问题.我们先脑补这样一个测试场景,你在页面A点击一个连接,会在新的 tab窗口打开页面B,这个时候,你 ...

  6. 2,PyAudio 实现录音 自动化交互实现问答

    Python 很强大其原因就是因为它庞大的三方库 , 资源是非常的丰富 , 当然也不会缺少关于音频的库 关于音频, PyAudio 这个库, 可以实现开启麦克风录音, 可以播放音频文件等等,此刻我们不 ...

  7. 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(二):Apache安装和配置

    基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...

  8. 转载:BUG定位

    1.web前端 Web前端就是通常说的网页.互联网公司的前端一般包含如下内容:JavaScript.ActionScript.CSS.HTML(..ML).Flash.交互式设计.视觉设计 web前端 ...

  9. 2 web服务器:固定返回值

    1.老师给的思路 #tcp socket 服务端 socket = socket.socket() socket.bind() socket.listen() client_socket = sock ...

  10. html页面导出word文档

    1.加入两个外部js 1)FileSaver.js /* FileSaver.js * A saveAs() FileSaver implementation. * 1.3.2 * 2016-06-1 ...