POJ 2777(涂点问线)
来源:互联网 发布:debian ubuntu 内存 编辑:程序博客网 时间:2024/06/06 07:31
线段树……
Program p2777;const maxl=100000; maxt=30; maxo=100000;var l,t,o,i,j,k:longint; col:array[1..maxl*10] of longint; c:char; x,y,color:longint; visit:array[1..maxt] of boolean;procedure build(l,r,root:longint);var mid:longint;begin if l=r then begin col[root]:=1; exit; end; mid:=(l+r) shr 1; build(l,mid,root shl 1); build(mid+1,r,root shl 1+1); col[root]:=1;end;procedure swap(var a,b:longint);var p:longint;begin p:=a;a:=b;b:=p;end;procedure detate(l,r,sonl,sonr,root,color:longint);var i,j,mid:longint;begin mid:=(l+r) shr 1; if l=r then begin col[root]:=color; exit; end; if (sonl<=l) and (r<=sonr) then begin col[root]:=color; exit; end; if col[root]>0 then begin col[root*2]:=col[root]; col[root*2+1]:=col[root]; col[root]:=-1; end; if not((mid<sonl) or (sonr<l)) then detate(l,mid,sonl,sonr,root shl 1,color); if not((r<sonl) or (sonr<mid+1)) then detate(mid+1,r,sonl,sonr,root shl 1+1,color);end;function quere(l,r,sonl,sonr,root:longint):longint;var mid,i,j:longint;begin quere:=0; mid:=(l+r) shr 1; if col[root]>0 then begin if not(visit[col[root]]) then begin visit[col[root]]:=true; exit(1); end; exit(0); end; if not((mid<sonl) or (sonr<l)) then inc(quere,quere(l,mid,sonl,sonr,root shl 1)); if not((r<sonl) or (sonr<mid+1)) then inc(quere,quere(mid+1,r,sonl,sonr,root shl 1+1));end;begin readln(l,t,o); build(1,l,1); for i:=1 to o do begin read(c); if c='C' then begin readln(x,y,color); if x>y then swap(x,y); detate(1,l,x,y,1,color); end else begin readln(x,y); if x>y then swap(x,y); fillchar(visit,sizeof(visit),false); writeln(quere(1,l,x,y,1)); end; end;end.
- POJ 2777(涂点问线)
- poj 2777(线段树)
- poj 2777(线段树)
- POj 2777(线段树)
- poj 2777
- poj 2777
- poj 2777
- poj 2777
- poj 2777
- POJ 2777
- POJ 2777
- poj-2777
- poj 2777
- poj 2777
- POJ 2777
- poj 2777
- poj 2777
- poj 2777
- HDU4091 Zombie’s Treasure Chest
- iphone 地图 根据地址获取经纬度
- 1.JSTL国际化:界面
- 微软时隔25年后再次更换Logo
- 2.JSTL国际化:资源文件
- POJ 2777(涂点问线)
- KVM 网络 资料整理(网上收集)(这个真的很好)
- 使用hash直接登陆windows
- 提供 云上有价值的服务
- onAttachedToWindow () 和 onDetachedFromWindow ()
- 设计模式--观察者模式(行为类模式)
- VC++多线程编程实例讲解(入门)
- Android源码二次开发+ubantu11.10配置Android 开发环境
- 利用inf文件添加shift后门