太太太太太太太恶心了 不想多说,完全就是特判判过的。。 花了我差不多3天时间,1天yy,1天画图,1天debug ms现在的程序还有一大堆问题,不想再调了,不过总算是把当时的数据a了 哎哟。。 {$M 10000000} // draw.txt program syj; uses math; const o:array[false..true,false..true]of longint=((1,0),(0,-1)); var e,root,n,x,y,z,ll,i,j,k,jj,l1,l2,ans:longint; gl,gr:boolean; fh,l,r,h,hl,hr,b,mh,h1,h2,h3,h4:array[0..100005]of longint; last:array[1..4,1..100005]of longint; next,point,p2:array[1..800005]of longint; procedure update(i:longint); begin mh[i]:=max(h[i],max(mh[l[i]],mh[r[i]])); fh[i]:=ord(mh[l[i]]=mh[i])*fh[l[i]] +ord(mh[r[i]]=mh[i])*fh[r[i]] +ord(h[i]=mh[i])*o[hr[l[i]]=mh[i],hl[r[i]]=mh[i]]; if l[i]<>0 then hl[i]:=hl[l[i]] else hl[i]:=h[i]; if r[i]<>0 then hr[i]:=hr[r[i]] else hr[i]:=h[i]; end; procedure left(var i:longint); var j:longint; begin j:=r[i];r[i]:=l[j];l[j]:=i; update(i);update(j); i:=j; end; procedure right(var i:longint); var j:longint; begin j:=l[i];l[i]:=r[j];r[j]:=i; update(i);update(j); i:=j; end; procedure put(i,k:longint); begin if i>0 then begin b[i]:=k;h[i]:=k;mh[i]:=k;fh[i]:=1;hl[i]:=k;hr[i]:=k; end; end; procedure splay(var i:longint;k:longint); begin if b[i]<>0 then begin put(l[i],b[i]);put(r[i],b[i]);b[i]:=0; end; if k<i then begin splay(l[i],k); right(i); end else if k>i then begin splay(r[i],k); left(i); end; end; procedure find(var j:longint;zz,x:longint); begin while (j>0)and(point[j]<jj) do j:=next[j]; while (j>0)and(point[j]<=jj+z) do begin inc(ans); j:=next[j]; gr:=true; end; if j=0 then last[zz,x]:=0; end; procedure add(i,k,z:longint); begin inc(e); point[e]:=k; if last[z,i]=0 then begin if z=1 then h1[i]:=e else h2[i]:=e; end else next[last[z,i]]:=e; last[z,i]:=e; end; function build(ll,rr:longint):longint; var mid:longint; begin if ll>rr then exit(0); mid:=(ll+rr) div 2; fh[mid]:=1; l[mid]:=build(ll,mid-1);r[mid]:=build(mid+1,rr); build:=mid; end; function dang(i,k,zz:longint):boolean; var j:longint; begin if zz=3 then j:=h3[i] else j:=h4[i]; while (j>0)and(p2[j]<k) do j:=next[j]; if (j>0)and(point[j]<=k+z) then dang:=true else dang:=false; if zz=3 then h3[i]:=j else h4[i]:=j; if j=0 then last[zz,i]:=0; end; begin assign(input,'input.txt');reset(input); assign(output,'output.txt');rewrite(output); readln(n); root:=build(1,100002);fh[0]:=1; for i:=1 to n do begin if i mod 5=0 then splay(root,random(n)+1); ans:=0; gl:=false;gr:=false; readln(x,y,z); inc(x,2);inc(y); // find gou zi splay(root,x-1);splay(root,y+1);jj:=mh[r[l[root]]]; splay(root,x); ll:=h[root]; j:=ll; find(h2[x],2,x); gl:=gr;gr:=false; splay(root,y); ll:=h[root]; k:=ll; find(h1[y],1,y); // normal splay(root,x-1); l1:=h[root]; splay(root,y+1); l2:=h[root]; inc(ans,fh[r[l[root]]]-1); if (j<jj)and dang(x-1,jj,4)and (not gl or (point[h4[x-1]]<=jj)) then inc(ans); if (k<jj)and dang(y+1,jj,3)and (not gr or (point[h3[y+1]]<=jj)) then inc(ans); put(r[l[root]],jj+z); // update gou zi splay(root,x); ll:=h[root]; if (j+z<ll)and(l1<ll-z) then add(x-1,ll-z,1); splay(root,y); ll:=h[root]; if (k+z<ll)and(l2<ll-z) then add(y+1,ll-z,2); // update dang inc(e); point[e]:=jj+1;p2[e]:=jj+z; if last[3,x]=0 then h3[x]:=e else begin next[last[3,x]]:=e; end; last[3,x]:=e; inc(e); point[e]:=jj+1;p2[e]:=jj+z; if last[4,y]=0 then h4[y]:=e else begin next[last[4,y]]:=e; end; last[4,y]:=e; writeln(ans); end; close(input);close(output); end. 附画图程序一个 program syj; var n,x,y,z,i,j,l,k:longint; a:array[1..1005,0..100000]of longint; begin assign(input,'input.txt');reset(input); assign(output,'draw.txt');rewrite(output); readln(n); for i:=1 to n do begin readln(x,y,z);inc(x,2);inc(y); k:=0; for j:=x to y do if a[j,0]>k then k:=a[j,0]; for j:=x to y do begin a[j,0]:=k+z; for l:=k+1 to k+z do a[j,l]:=1; end; end; for j:=1 to 2000 do begin for i:=1 to 1000 do if a[i,j]=1 then write('.') else write(' '); writeln; end; close(input);close(output); end.