题目
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
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
提问时间:2021-02-25
答案
请等一下 我在看你的程序.
我也搞过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
我也搞过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
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
- 1用惰性电极电解亚硫酸钠溶液的电极方程式如何写
- 2已知△ABC是三边为整数的直角三角形,BC为斜边,且2AC=BC+AB,则BC:AC:AB是多少?
- 3请问暑假作业不会做《关于英语方面的一些问题》谁回答我
- 4上周你去阿姨家了吗,翻译英文
- 5如果a=3,b=2,且b是a和c的比例中项,那么c=( ) A.±23 B.23 C.43 D.±43
- 6双星系统的特点
- 7到空间四点距离相等的平面的个数为_.
- 8查找一篇团员教育评议自我小结怎么写
- 9某校七年级英语口试达到优秀标准的有70人,占总人数的6分之1,则总人数为______人.
- 10在那些岁月里他们处境很困难 英语翻译 I hope ___ ___ you again ___ next year.
热门考点
- 1That girl can swim fast.(run fast)改写句子
- 2物理中G表和A表的区别?
- 3某工程由甲、乙两队合做6天完成,厂家需付甲、乙两队共4350元;乙、丙两队合做10天完成,厂家需付乙、丙两队共4750元;甲、丙两队合做5天完成全部工程的2/3,厂家需付甲、丙两队共2750元
- 4have ever met someone who you knew would change your life forever
- 5用三种方法把长方形分成四个相同的三角形
- 6翻译句子:1.你们订票了吗?2.在我忙的时候不要打扰我.
- 74.78乘1.5的积减去0.6除以0.4的商,差是多少?
- 81.
- 9如图.在平行四边形ABCD 中.BF平分∠ABE.EF平行AB.求证AE⊥BF
- 10数列{an}中有a1=1,a(n+3)= an+3,a(n+2)≥an+2 (n∈N*) (1) 求a7,a5,a3,a6 ;