|  | 
|  | 
| back to board | Do you have any goodidea? Posted by Tony  7 Oct 2002 11:32Re: Do you have any goodidea? Posted by VladG  13 Nov 2002 10:56>Just insert numbers to the binary tree and then print them in the
 order you want.
Re: Do you have any goodidea? Posted by fk999  1 Aug 2003 21:18> >> rubbish!
Re: Do you have any goodidea? Posted by PSV  25 Mar 2007 21:51Yeah!!Try to see structure of input and output strings. Resursion-recursion.
Re: Do you have any goodidea? program timus1136a;
 {$APPTYPE CONSOLE}
 
 uses
 SysUtils;
 const mz=100000;
 var a,b:array[0..3000] of longint;n,i,p,q:longint;
 procedure f(u,r,t:longint);begin
 if(a[u]<r){l} then begin p:=u;exit;end;
 f(u-1,a[u],t);
 f(p,r,a[u]);
 inc(q);b[q]:=a[u];if u<=p then p:=u-1;
 end;
 begin
 read(n);
 for i := 1 to n do  read(a[i]);a[0]:=-1;
 p:=n;q:=0;
 f(n,0,mz);
 for i := 1 to n-1 do write(b[i],' ');write(b[n]);
 
 end.
 | 
 | 
|