ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1136. Parliament

Do you have any goodidea?
Posted by Tony 7 Oct 2002 11:32
Re: 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:51
Yeah!!
Try to see structure of input and output strings. Resursion-recursion.
Re: Do you have any goodidea?
Posted by xMagGTU Дмитрий Тишкин GPRS 2 Jan 2008 18:01
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.