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代码整合
随机推荐
- laravel路由组+中间件
在rotues中的web.php
- python爬取豆瓣流浪地球影评,生成词云
代码很简单,一看就懂. (没有模拟点击,所以都是未展开的) 地址: https://movie.douban.com/subject/26266893/reviews?rating=&star ...
- POJ1426 Find The Multiple 解题报告
参考:http://www.cnblogs.com/ACShiryu/archive/2011/07/24/2115356.html #include <iostream> #includ ...
- CONCATENATE命令(文字列の結合)
CONCATENATE命令とは文字列の結合を行う命令である.文字列を扱うChar, Numeric, Dats, Time, Stringの変数で使用する事が可能だ.単純に文字列の結合のみを行う方法. ...
- C# 集合之Dictionary详解
开讲. 我们知道Dictionary的最大特点就是可以通过任意类型的key寻找值.而且是通过索引,速度极快. 该特点主要意义:数组能通过索引快速寻址,其他的集合基本都是以此为基础进行扩展而已. 但其索 ...
- Moodle 3.4中添加小组、大组、群
Moodle在高中应用时经常要用到年级.班级和小组,我们可以用群.大组.小组来代替. 小组设置:网站首页-->现有课程-->右上角的设置按钮-->更多-->用户-->小组 ...
- Office Web Apps Server(1)
Office Web Apps Server runs on one or more servers and provides browser-based Office file viewi ...
- Asp.NET Core2.0与 EF的ABP框架入门视频教程
https://ke.qq.com/course/287301?from=qqchat&ADUIN=1187219916&ADSESSION=1522716499&ADTAG= ...
- CSS : @media 示例
.example { padding: 20px; color: white; } /* Extra small devices (phones, 600px and down) */ @media ...
- Word2vec之CBOW
一.Word2vec word2vec是Google与2013年开源推出的一个用于获取word vecter的工具包,利用神经网络为单词寻找一个连续向量看空间中的表示.word2vec是将单词转换为向 ...