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

Common Board

Hi, i need the algorithm to do an euler path (+)
Posted by Miguel Angel 11 Jun 2002 00:57
I know the definition of a euler path, but i don't know how to
implement it efficently, could someone help?, and tell me how is
possible to do a the problem "Bus Routes" with only 49 k??.. (i see
it in the list, is from someone from IFMO i belive).
Mail: miguelangelhdz@hotmail.com
Thanks in advance :)
Re: Hi, i need the algorithm to do an euler path (+)
Posted by Andrey Popyk (popyk@ief.tup.km.ua) 11 Jun 2002 16:46
Let St - stack; V1 - Odd vertex (or even, if graf has no odd)

St=empty stack;
Put V1 to St;
while St not empty do
begin
  V=St.top; //without extract from stack
  if there is an edge (V,i)
    then begin Put i to stack, remove edge (V,i) end
    else begin Write V to output remove V from St end;
end;

After such algorithm you have a Reversed Euler path in the output.

Andrey Popyk.
E-Mail: popyk@ief.tup.km.ua
ICQ# 88914410

> I know the definition of a euler path, but i don't know how to
> implement it efficently, could someone help?, and tell me how is
> possible to do a the problem "Bus Routes" with only 49 k??.. (i see
> it in the list, is from someone from IFMO i belive).
> Mail: miguelangelhdz@hotmail.com
> Thanks in advance :)