type node=^link; link=record des:longint; next:node; end; type seg=record z,y,lc,rc,toadd,sum:longint; end; var n,tot,i,t1,t2,q,a,b,c:longint; p:node; son,siz,dep,fa,num,top:..] of longint; tr:..] of seg; nd:..] of node; function max(a,b:longint):lon…