ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Общий форум

Hi, i need the algorithm to do an euler path (+)
Послано Miguel Angel 11 июн 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 (+)
Послано Andrey Popyk (popyk@ief.tup.km.ua) 11 июн 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 :)