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个字面意 ...
随机推荐
- 关于js封装框架类库之选择器引擎(二)
在上篇介绍了选择器的获取标签.id.类名的方法,现在我们在上篇基础上继续升级 1.问题描述:上篇get('选择器')已经实现,如果get方法里是一个选择器的父元素,父元素是DOM对象,那么如何获取元素 ...
- window.showModalDialog刷新父窗口和本窗口的方法及注意
window.showModalDialog刷新父窗口和本窗口的方法及注意: 一.刷新父窗口的方法: A.使用window.returnValue给父窗口传值,然后根据值判断是否刷新. 在w ...
- 【原创】ASP.NET Web开发,实现打印Log日志,步骤详解
添加Log需要四步: 一.引用log4net.dll,详见附件:http://pan.baidu.com/s/1c0hab2g 二.项目根目录下,添加 log4net.xml <?xml ver ...
- 面试题之请写出用于校验 HTML 文本框中输入的内容全部为数字 的 javascript 代码
<input type="text" id="d1" onblur=" chkNumber(this)"/> <scrip ...
- [Jobdu] 题目1520:树的子结构
题目描述: 输入两颗二叉树A,B,判断B是不是A的子结构.注:B为空树时不为任何树的子树 typedef struct BTNode{ int key; struct BTNode *rchild; ...
- BZOJ 1034: [ZJOI2008]泡泡堂BNB( 贪心 )
贪心...用最弱的赢最弱的,用最强的赢最强的,否则用最弱的和最强的比... (贴个官方题解:将双方的选手均按从强到弱排序,然后第一次扫描尽可能用当前剩下的选手中能赢对手当前最强选手中最弱的一个去赢得胜 ...
- (Problem 53)Combinatoric selections
There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...
- TortoiseSVN是windows平台下Subversion的免费开源客户端。
一般我们都是先讲讲服务器的配置,然后再讲客户端的使用,但是在TortoiseSVN上,却可以反过来.因为,如果你的要求不高,只是想在本机,或者是可信任的局域网络中使用SVN版本控制,可以不需要安装SV ...
- 部署vc2008开发的程序(vcredist_x86是其中一个办法)
如果你编译了一个VC2008的默认的CRT/MFC的应用程序,如果目标部署电脑上没有安装相应的VC2008的动态库,当运行你的程序的时 个,会出现如下错误信息. 这是因为程序使用了基于VC2008 ...
- php 实现简单的登录
//登录页面: V层前端模板: Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp/Home/Tpl/Login $ ls inde ...