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个字面意 ...
随机推荐
- Boost源代码学习---shared_ptr.hpp
最近观看Boost库源代码.Boost功能强大的库,但它的许多源代码,十一细读太费时间,毕竟,还有其他东西要学.所以我决定脱脂感兴趣的章节,他们的设计思路和难以理解的地方记录. shared_ptr是 ...
- BootStrap 智能表单系列 首页 (持续更新中...)
背景:本码农.NET后端工程师,在项目开发中发现写了很多重复的代码, 于是自己整了一套根据配置来生成form表单的插件,针对表单的改动仅需要修改配置的json即可 使用中发现还是蛮实用的,于是开源出来 ...
- linux定时任务crontab的设置
linux定时任务crontab的设置http://www.blogjava.net/freeman1984/archive/2010/09/23/332715.html vi /etc/cronta ...
- Java Socket编程 标准范例(多线程)
链接地址:http://blog.csdn.net/benweizhu/article/details/6615542 服务器端(Server)非多线程 package com.zeph.server ...
- php 图片等比缩放
/** * @method 图片等比缩放 * @param string $srcImage 源图片路径 * @param string $toFile 目标图片路径 * @param integer ...
- python自定义排序函数
Python内置的 sorted()函数可对list进行排序: >>>sorted([36, 5, 12, 9, 21]) [5, 9, 12, 21, 36] 但 sorted() ...
- idea中使用sbt构建scala项目及依赖
1.安装scala插件 http://www.cnblogs.com/yrqiang/p/5310700.html 2. 详细了解sbt: http://www.scala-sbt.org/0.13/ ...
- IOS UIActionSheet的使用方法
在IOS的用户接口向导中,苹果提供了另外一种显示警告框的手法,叫做UIActionSheet.它和UIAlertView比起来不会显得过于急切和紧张.而是很温和地在继续流程之前给用户提供了诸多选择. ...
- Move WriteBuffer ReadBuffer String
在实际编程中,经常会用到Buffer,当string作为Buffer传值时需要注意的是 1, string的值的起始索引是1,千万记住! 2, 有时候需要先告诉系统去开辟出内存空间,用SetLengt ...
- MFC模式对话框与非模式对话框 消息处理顺序
对话框有两种创建方式:DoModal和Creat. 其中DoModal创建的是模态的对话框,而Creat创建的是非模态的对话框下面总结下他们的不同. 对于模态的对话框,在该对话框被关闭前,用户将不能在 ...