請(qǐng)等一下 我在看你的程序.
我也搞過(guò)OI
能補(bǔ)充一下問(wèn)題是什么嗎.
我的機(jī)子上沒(méi)有FP
要幫您調(diào)試的話稍等下
經(jīng)過(guò)我簡(jiǎn)單的調(diào)試
發(fā)現(xiàn)ins過(guò)程中少了一的exit導(dǎo)致201暴棧
如果沒(méi)有其他錯(cuò)誤因該是
在da[v].val:=a;后加一個(gè)exit;
我本人寫(xiě)c++的 pascal可能寫(xiě)不好.
正確程序:
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
type my=record
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
其他人氣:294 ℃時(shí)間:2020-04-10 01:15:14
優(yōu)質(zhì)解答
我來(lái)回答
類(lèi)似推薦
- 地暖進(jìn)水管和回水管都開(kāi)著,水不循環(huán)什么原因
- 培優(yōu)訓(xùn)練
- "紀(jì)昌學(xué)射"```幫幫忙啊```
- 已知二次函數(shù)f(x)是偶函數(shù),且經(jīng)過(guò)點(diǎn)(3,6)求它的解析式.謝
- “理想很豐滿,現(xiàn)實(shí)很骨感”這句話是什么意思呀?
- it is convenient for you to do 這里for you在句中是什么結(jié)構(gòu)
- 將na2co3和nahco3混合物30克配成一升溶液,測(cè)得溶液的ph=10.62,溶液含NA2CO3幾克?
- 有關(guān)于Lg的計(jì)算
- 對(duì)冪指函數(shù)兩邊求導(dǎo)?
- a比b多25%,b比a少( )%
- 物質(zhì)的量濃度相等的醋酸和醋酸鈉溶液等體積混合,兩倍的鈉離子=醋酸根+醋酸,這個(gè)是怎么來(lái)的?
- 一箱蘋(píng)果,吃了2/5,吃了18顆,這箱蘋(píng)果原有_顆.
猜你喜歡
- 1問(wèn)幾道小學(xué)六年級(jí)數(shù)學(xué)的題,分高.
- 2向量的運(yùn)算法則
- 3did what buy food you for Daming 怎么排列順序
- 4z=1+根號(hào)3i分之-2,i為虛數(shù)單位,argz=
- 5寫(xiě)兩篇關(guān)于治水金點(diǎn)子的作文
- 6甲乙兩人從a地到b地,甲需1小時(shí),乙需40分鐘,若甲先出發(fā)10分鐘,則乙追上甲需用多少分鐘 要算式和講解.
- 7求翻譯一下這段內(nèi)容,謝謝!
- 8try ……on的意思
- 9but的用法之一
- 10Li Guanghua is good at playing foot.(同義句轉(zhuǎn)化)LI Guanghua is ()very ()()().
- 11______ (Much/Lots) of them can speak English quite well.
- 12雞的只數(shù)是鴨的2分之1,鵝的只數(shù)是雞的3分之1,鵝的只數(shù)為鴨的幾分之幾?