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的更多相关文章

  1. [BZOJ 1018] [SHOI2008] 堵塞的交通traffic 【线段树维护联通性】

    题目链接:BZOJ - 1018 题目分析 这道题就说明了刷题少,比赛就容易跪..SDOI Round1 Day2 T3 就是与这道题类似的..然而我并没有做过这道题.. 这道题是线段树维护联通性的经 ...

  2. BZOJ 1018 堵塞的交通traffic(线段树)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1018 题意:一个2*n的格子,相邻格子之间有一条道路.初始时道路是不通的. 三种操作:( ...

  3. BZOJ 1018 堵塞的交通

    Description 有一天,由于某种穿越现象作用,你来到了传说中的小人国.小人国的布局非常奇特,整个国家的交通系统可以被看成是一个2行C列的矩形网格,网格上的每个点代表一个城市,相邻的城市之间有一 ...

  4. 数据结构(线段树):BZOJ 1018: [SHOI2008]堵塞的交通traffic

    1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 2638  Solved: 864 Descri ...

  5. BZOJ 1018 [SHOI2008]堵塞的交通traffic

    1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 2247  Solved: 706[Submit ...

  6. BZOJ 1018: [SHOI2008]堵塞的交通traffic(线段树)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1018 用线段树维护区间连通性,对于每一个区间记录6个域表示(左上,左下)(左上,右上)(右上, ...

  7. BZOJ 1018: [SHOI2008]堵塞的交通traffic [线段树 区间信息]

    1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 3064  Solved: 1027[Submi ...

  8. 【BZOJ 1018】线段树 **

    1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 3242  Solved: 1084[Submi ...

  9. bzoj 1018 线段树维护连通性

    本题将一道LCT的题特殊化(支持加边和删边,询问图的连通性),将图变成了2×m的网格图,然后就神奇地可以用线段树来维护. 对于每个区间[l,r],维护其四个角落之间的连通性(仅仅通过[l,r]这段的边 ...

  10. 【BZOJ 1018】【SHOI 2008】堵塞的交通traffic

    http://www.lydsy.com/JudgeOnline/problem.php?id=1018 线段树维护连通性. 把每一列看成一个节点,对于线段树上的每一个节点,维护8个信息,前6个字面意 ...

随机推荐

  1. Grunt的配置和使用(一)

    Grunt的配置和使用(一) Grunt 和 Grunt 的插件都是通过 Node.js 的包管理器 npm 来安装和管理的.为了方便使用 Grunt ,你应该在全局范围内安装 Grunt 的命令行接 ...

  2. iOS面试题02-数据存储

    1.如果后期需要增加数据库中的字段怎么实现,如果不使用CoreData呢? 回答:编写SQL语句来操作原来表中的字段 1>增加表字段 ALETER TABLE 表名 ADD COLUMN 字段名 ...

  3. js中Date对象

    Date常用的几个方法: var oDate=new Date(); oDate.getHours()方法是获取当前的小时 oDate.getMinutes()方法获取当前的分钟 oDate.getS ...

  4. LINQ实现行列转换

    用SQL语句实现行列转换很容易,但也有时候需要在程序中实现,找了好久,发现一篇文章写的挺不错的 http://blog.csdn.net/smartsmile2012/article/details/ ...

  5. jar 包和批量处理

    打jar包: 选择要打包的文件: javac -d . Hello.java .代表打包的目标路径 jar cvf test.jar com  //test是打包名称,com是打包的文件夹 修改tes ...

  6. BZOJAC400题留念

    BZOJAC400题了...

  7. android手机关于google play商店闪退的解决办法

    部分android手机没有安装google play商店,这个可以通过类似“机锋”.“360手机助手”等应用市场下载. 安装google play商店后,点击打开却一闪而过:这个问题是因为手机没有安装 ...

  8. python自学笔记(四)python基本数据类型之元组、集合、字典

    一.元组tuple 特性 1.有序集合 2.通过偏移来取数据 3.不可变对象,不能在原地修改内存,没有排序.修改等操作 元组不可变的好处:保证数据的安全,比如我们传给一个不熟悉的方法,确保不会改变我们 ...

  9. 设置MAVEN_OPTS的推荐方法

    运行mvn eclipse:eclipse时,经常会出现因为maven项目过大,导致内存不足java栈溢出的error,需要更改MAVEN启动内存 http://stackoverflow.com/q ...

  10. 磁盘IO子系统学习资料

    1.http://www.ibm.com/developerworks/cn/linux/l-cn-read/    (IBM read系统调用剖析) 2.http://lenky.info/arch ...