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. MinGW gcc 生成动态链接库 dll 的一些问题汇总 (补充)

    我以前写过一个小短文,介绍MinGW gcc 生成动态链接库 dll 的一些问题.当时写的并不全面.近期又遇到写新的问题.这里记录一下,做个补充. 通常情况下,dll 中的函数假设採用 _stdcal ...

  2. linux之线程

    http://blog.csdn.net/lanyan822/article/details/7586845 POSIX线程数据类型: pthread_t 线程标识符: pthread_mutex_t ...

  3. webform 不实用office控件导出excel StringBuilder 类型拼接字符串表格导出excel

    StringBuilder sb = new StringBuilder(); sb.AppendLine("<meta http-equiv=\"Content-Type\ ...

  4. ADO.NET知识的运用一(Day 26)

    哈哈,又到了总结的时间了,来回顾一下今天主要学了关于ADO.NET的哪些知识吧.(这次学的ADO访问数据库主要以访问SQL数据库为主) 理论:  首先我们要知道为什么要学习ADO.NET? 因为我们之 ...

  5. 磁盘性能,你可能不知道的IOPS计算方法

    每个I/O 请求到磁盘都需要若干时间.主要是因为磁盘的盘边必须旋转,机头必须寻道.磁盘的旋转常常被称为”rotational delay”(RD),机头的移动称为”disk seek”(DS).一个I ...

  6. 加密PHP文件的方式,目测这样可以写个DLL来加密了

    <?php function encode_file_contents($filename) { $type=strtolower(substr(strrchr($filename,'.'),1 ...

  7. A Byte of Python 笔记(7)数据结构:列表、元组、字典,序列

    第9章 数据结构 数据结构,即可以处理一些数据的结构.或者说,它们是用来存储一组相关数据的. python 有三种内建的数据结构--列表.元组和字典. list = ['item1', 'item2' ...

  8. python之math模块

    1.math简介 >>>import math #导入math模块 >>>dir(math) #这句可查看所有函数名列表 >>>help(math ...

  9. Object-c Block的使用及说明

    Object-c 中的block就好像一段C函数般,由函数名,有返回值,有参数,由函数体等 1.简单的block ^(int A ,int B) { int C=A*B; return C; }; 上 ...

  10. web 性能优化指南阅读笔记

    1.关于拥塞预防算法 PRR-比例降速,RFC6937 规定的一个新算法,其目标是改进丢包后的恢复速度,谷歌测量结果:该算法改进丢包造成的平均连接延迟减少了3%-10%.PRR是linux 3.2+内 ...