Power Tree slow by nn

f={v->v&&[f(p[v]),p[v+=j]||[p[v]=j,a<<v]]}
p=[i=0,0,1]
a=[2]
l=System.in.text
n=l[1..-1]as int
for(o=l<'t'?n:'';i>2e3?[o=p[n]+' '+o,n=l<'t'?p[n]:n-1][1]>1:f(j=a[i++]););
print o

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page