type my=recordval,l,r:longint;end;var n,i,root,a,ppool:longint;da:array[0..100010]of my;procedure print(v:longint);beginif v=0 then exit;print(da[v].l);write(da[v].val,' ');print(da[v].r);end;procedure ins(var v:longint;a:longint);beginif v=0 thenbeg

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 17:30:27
type my=recordval,l,r:longint;end;var n,i,root,a,ppool:longint;da:array[0..100010]of my;procedure print(v:longint);beginif v=0 then exit;print(da[v].l);write(da[v].val,' ');print(da[v].r);end;procedure ins(var v:longint;a:longint);beginif v=0 thenbeg
xWrV~ ]"IJ3YF K@ܤNx3ms)Mda:t2-e$ߢ&H hWv\Cѡt`k,R`r-Fa! tuNJ Z ;5X,ZRN\4 aaZf[ꪄ:-4fahڗDTw;r]Ǵ5Τ]iLT I*]ȥjB(k!Vrd L)I]>n(gX3+ MZϏb?Rсs:||̎?ǯ>s}x8;7/z?=qp4 .׳pYw_xqp1-&?LJҁDmG8'rRjL`":g0$lHx &,D-އ݃! ~󯿿b2 ~8]Lq j4NPp,xzJ9Y ,f͍ UrA hRzp2..}R\hȒa LǖWJ#ƜnH ;t>&rpxB`m+)H%u$Tºr2i㞱SIFlf!WFh cհ^$PٓW\ enu$ԕee Yh3N4}anEa~`40\+f8.#/) .+ +ZrP)>3IH*扭ҩbCsLӄQˌQ(w:ZG]^ B7\<0q4#KaN;<1ԔH–'D^bJai˅j=]!Ig ݈^j7&[6햰wcZYI`+_c3%>nIe-ߩ͛O7*5Kyӱ; ;tO5,AZRRB/SeJW p}'

type my=recordval,l,r:longint;end;var n,i,root,a,ppool:longint;da:array[0..100010]of my;procedure print(v:longint);beginif v=0 then exit;print(da[v].l);write(da[v].val,' ');print(da[v].r);end;procedure ins(var v:longint;a:longint);beginif v=0 thenbeg
type my=record
val,l,r:longint;
end;
var n,i,root,a,ppool:longint;
da:array[0..100010]of my;
procedure print(v:longint);
begin
if v=0 then exit;
print(da[v].l);
write(da[v].val,' ');
print(da[v].r);
end;
procedure ins(var v:longint;a:longint);
begin
if v=0 then
begin
inc(ppool);
v:=ppool;
da[v].val:=a;
end;
if a

type my=recordval,l,r:longint;end;var n,i,root,a,ppool:longint;da:array[0..100010]of my;procedure print(v:longint);beginif v=0 then exit;print(da[v].l);write(da[v].val,' ');print(da[v].r);end;procedure ins(var v:longint;a:longint);beginif v=0 thenbeg
请等一下 我在看你的程序.
我也搞过OI
能补充一下问题是什么吗.
我的机子上没有FP
要帮您调试的话稍等下
经过我简单的调试
发现ins过程中少了一的exit导致201暴栈
如果没有其他错误因该是
在da[v].val:=a;后加一个exit;
我本人写c++的 pascal可能写不好.
正确程序:
type my=record
val,l,r:longint;
end;
var n,i,root,a,ppool:longint;
da:array[0..100010]of my;
procedure print(v:longint);
begin
if v=0 then exit;
print(da[v].l);
write(da[v].val,' ');
print(da[v].r);
end;
procedure ins(var v:longint;a:longint);
begin
if v=0 then
begin
inc(ppool);
v:=ppool;
da[v].val:=a;
exit;
end;
if ab then exit(b) else exit(a);
end;
function max(a,b:longint):longint;
begin
if a>b then exit(a) else exit(b);
end;
constructor Ttreap.init;
begin
randomize;
total:=1;
with t[total] do
begin
total:=1;
key:=-1;
value:=-1;
fa:=0;
end;
root:=1;
end;
procedure Ttreap.turn(father,son:longint);
begin
t[son].fa:=t[father].fa;
if t[t[father].fa].right=father then t[t[father].fa].right:=son
else t[t[father].fa].left:=son;
t[father].fa:=son;
if t[father].right=son then
begin
t[t[son].left].fa:=father;
t[father].right:=t[son].left;
t[son].left:=father;
end
else
begin
t[t[son].right].fa:=father;
t[father].left:=t[son].right;
t[son].right:=father;
end;
t[son].total:=t[father].total;
t[father].total:=t[t[father].left].total+t[t[father].right].total+1;
end;
procedure Ttreap.insert(x:longint);
var
i,last:longint;
begin
i:=root;
while i0 do
begin
last:=i;
inc(t[i].total);
if x>t[i].value then i:=t[i].right
else i:=t[i].left;
end;
inc(total);
with t[total] do
begin
total:=1;
key:=random(range);
value:=x;
left:=0;
right:=0;
fa:=last;
end;
if x>t[last].value then t[last].right:=total else t[last].left:=total;
while t[total].keyt[i].value then i:=t[i].right
else
begin
h:=i;
i:=t[i].left;
end;
end;
t[h].value:=t[last].value;
t[h].key:=t[last].key;
if t[last].left=0 then k:=t[last].right else k:=t[last].left;
j:=t[last].fa;
t[k].fa:=j;
if t[j].left=last then t[j].left:=k else t[j].right:=k;
end;
function Ttreap.find(x:longint):longint;
var
i:longint;
begin
i:=t[root].right;
while x>0 do
begin
if t[t[i].left].total+1=x then exit(t[i].value);
if t[t[i].left].total>=x then i:=t[i].left
else
begin
x:=x-t[t[i].left].total-1;
i:=t[i].right;
end;
end;
end;
procedure qsort(left,right:longint);
var
i,j,x,xx:longint;
begin
i:=left;
j:=right;
x:=a[(i+j) shr 1];
xx:=b[(i+j) shr 1];
while i