BZOJ 1018
program bzoj1018;
type
node=array [..] of boolean;
pair=array [..] of boolean;
var
tot,c,i,j,k,x1,y1,x2,y2:longint;
ans:boolean;
ch:char;
x,y,z:node;
left,right:array [..] of longint;
stu:array [..] of node;
had:array [..]of pair; procedure swap(var a,b:longint);
begin
if a=b then exit;
a:=a xor b;
b:=a xor b;
a:=a xor b;
end; procedure build(s,e,now:longint);
var mid:longint;
begin
if s=e then
begin
stu[now][]:=true;
stu[now][]:=true;
exit;
end;
mid:=(s+e) >>;
inc(tot);
left[now]:=tot;
build(s,mid,tot);
inc(tot);
right[now]:=tot;
build(mid+,e,tot);
end; function update(a,b:node;had:pair):node;
var i,j,k:longint;
now:node;
begin
fillchar(now,sizeof(now),false);
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if had[] and a[] and b[] then now[]:=true;
if a[] then now[]:=true;
if a[] and a[] and had[] and had[] and b[] then now[]:=true;
if b[] then now[]:=true;
if b[] and b[] and had[] and had[] and a[] then now[]:=true;
exit(now);
end; procedure insertl(w:boolean;x,l,r,now:longint);
var mid:longint;
begin
if l=r then
begin
if w then
fillchar(stu[now],sizeof(stu[now]),true)
else
begin
fillchar(stu[now],sizeof(stu[now]),false);
stu[now][]:=true;
stu[now][]:=true;
end;
exit;
end;
mid:=(l+r)>>;
if x<=mid then insertl(w,x,l,mid,left[now])
else insertl(w,x,mid+,r,right[now]);
stu[now]:=update(stu[left[now]],stu[right[now]],had[now]);
end; procedure insertr(w:boolean;x,y,l,r,now:longint);
var mid:longint;
begin
mid:=(l+r)>>;
if x=mid then
begin
had[now][y]:=w;
stu[now]:=update(stu[left[now]],stu[right[now]],had[now]);
exit;
end;
if x<=mid then insertr(w,x,y,l,mid,left[now])
else insertr(w,x,y,mid+,r,right[now]);
stu[now]:=update(stu[left[now]],stu[right[now]],had[now]);
end; function find(x1,x2,l,r,now:longint):node;
var temp:node;
mid:longint;
begin
if(x1=l)and(x2=r) then exit(stu[now]);
mid:=(l+r)>>;
if x2<=mid then exit(find(x1,x2,l,mid,left[now]))
else
if x1>mid then exit(find(x1,x2,mid+,r,right[now]))
else exit(
update(find(x1,mid,l,mid,left[now]),
find(mid+,x2,mid+,r,right[now]),
had[now])
);
end; procedure main;
begin
readln(c);
build(,c,);
repeat
read(ch);
case ch of
'E':break;
'O':begin
read(ch,ch,ch,y1,x1,y2,x2);
dec(y1);
dec(y2);
if x1=x2 then insertl(true,x1,,c,)
else
if x1<x2 then insertr(true,x1,y1,,c,)
else insertr(true,x2,y1,,c,);
end;
'C':begin
read(ch,ch,ch,ch,y1,x1,y2,x2);
dec(y1);
dec(y2);
if x1=x2 then insertl(false,x1,,c,)
else
if x1<x2 then insertr(false,x1,y1,,c,)
else insertr(false,x2,y1,,c,);
end;
'A':begin
read(ch,ch,y1,x1,y2,x2);
dec(y1);
dec(y2);
if x1>x2 then
begin
swap(x1,x2);
swap(y1,y2);
end;
x:=find(,x1,,c,);
y:=find(x1,x2,,c,);
z:=find(x2,c,,c,);
ans:=false;
ans:=ans or y[y1*+y2];
ans:=ans or(x[] and y[(-y1)*+y2]);
ans:=ans or(z[] and y[y1*+-y2]);
ans:=ans or(x[] and z[] and y[(-y1)*+-y2]);
if ans then writeln('Y')
else writeln('N');
end;
end;
until false;
end; begin
main;
end.
BZOJ1018
BZOJ 1018的更多相关文章
- [BZOJ 1018] [SHOI2008] 堵塞的交通traffic 【线段树维护联通性】
题目链接:BZOJ - 1018 题目分析 这道题就说明了刷题少,比赛就容易跪..SDOI Round1 Day2 T3 就是与这道题类似的..然而我并没有做过这道题.. 这道题是线段树维护联通性的经 ...
- BZOJ 1018 堵塞的交通traffic(线段树)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1018 题意:一个2*n的格子,相邻格子之间有一条道路.初始时道路是不通的. 三种操作:( ...
- BZOJ 1018 堵塞的交通
Description 有一天,由于某种穿越现象作用,你来到了传说中的小人国.小人国的布局非常奇特,整个国家的交通系统可以被看成是一个2行C列的矩形网格,网格上的每个点代表一个城市,相邻的城市之间有一 ...
- 数据结构(线段树):BZOJ 1018: [SHOI2008]堵塞的交通traffic
1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 2638 Solved: 864 Descri ...
- BZOJ 1018 [SHOI2008]堵塞的交通traffic
1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 2247 Solved: 706[Submit ...
- BZOJ 1018: [SHOI2008]堵塞的交通traffic(线段树)
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1018 用线段树维护区间连通性,对于每一个区间记录6个域表示(左上,左下)(左上,右上)(右上, ...
- BZOJ 1018: [SHOI2008]堵塞的交通traffic [线段树 区间信息]
1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 3064 Solved: 1027[Submi ...
- 【BZOJ 1018】线段树 **
1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec Memory Limit: 162 MBSubmit: 3242 Solved: 1084[Submi ...
- bzoj 1018 线段树维护连通性
本题将一道LCT的题特殊化(支持加边和删边,询问图的连通性),将图变成了2×m的网格图,然后就神奇地可以用线段树来维护. 对于每个区间[l,r],维护其四个角落之间的连通性(仅仅通过[l,r]这段的边 ...
- 【BZOJ 1018】【SHOI 2008】堵塞的交通traffic
http://www.lydsy.com/JudgeOnline/problem.php?id=1018 线段树维护连通性. 把每一列看成一个节点,对于线段树上的每一个节点,维护8个信息,前6个字面意 ...
随机推荐
- Android 手势锁的实现 为了让自己的应用程序的安全,现在
转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/36236113 今天偶遇以github上gesturelock关于手势锁的一个样例 ...
- iOS中Block介绍 基础
ios开发block的使用指南,以及深入理解block的内存管理,也适用于osx开发.讨论范围:block的使用,内存管理,内部实现.不包含的内容:gc arc下的block内存,block在c++中 ...
- 对武汉-and-IT软件开发的看法
本编是一个武汉农村娃子,2015年毕业到现在算上实习 差不多快三年的时间了.在软件行业混的也就一般水平,从开心在学校学习的winform+DBHelper 的开发模式,到现在MVC+EF 的开发模式. ...
- 简单的web三层架构系统【第二版】
昨天写了 web三层架构的第一版,准确的说是三层架构的前期,顶多算是个二层架构,要慢慢完善. 第一版里,程序虽说能运行起来,但是有一个缺陷,就是里面的SQL语句,是使用的拼接字符进行执行.这样安全系数 ...
- android http同步请求
1.界面 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...
- MD5随机散列加密算法
项目中需要在登录验证用户名.密码的时候对密码进行加密处理,由于是比较商业化的软件,所以安全方面还是必须要考虑的.而使用MD5随机散列加密算法使得密码加密后不可逆,很大程度上提升了安全性.废话不多说,看 ...
- Objective-C继承
继承只是想谈谈在OC中继承的理解:面向对象语言中一个主要的功能就是继承.继承可以使用现在类的所用功能,是对功能的扩展,通过继承创建的新类称为“子类”或“派生类”,被继承的称为“基类”或者“父类”.继承 ...
- JBoss 系列二十一:JBossCache核心API
内容简介 本处介绍JBossCache相关的主要API,我们目的通过本部分描述,读者可以使用JBossCache API,在自己的应用中使用JBossCache. Cache接口 Cache 接口是和 ...
- Oracle 批量造数据
1.通过存储过程方式 CREATE OR REPLACE procedure XXZY.p_test is i number; begin .. loop INSERT INTO test_job V ...
- 在iOS上增加手势锁屏、解锁功能
在iOS上增加手势锁屏.解锁功能 在一些涉及个人隐私的场景下,尤其是当移动设备包含太多私密信息时,为用户的安全考虑是有必要的. 桌面版的QQ在很多年前就考虑到用户离开电脑后隐私泄露的危险,提供了“离开 ...