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

Обсуждение задачи 1056. Центры сети

Can somebody give me some hints on how to solve P1056?
Послано abc 6 фев 2003 11:58
Re: Can somebody give me some hints on how to solve P1056?
Послано Marcin Mika 25 фев 2003 02:51
1. the graph forms a tree
2. you need to give this tree direction (since the given tree is
undirected)
3. the longest path starting at node k is the maximum of 2 values:
the maximum path starting at k and going DOWN (a tree has no cycles
so you can solve this easily in linear time, i used simple DP)
and the maximum path by going UP from k.
Re: Can somebody give me some hints on how to solve P1056?
Послано Maigo Akisame 8 июн 2004 09:13
"the maximum path by going UP from k."

What do you mean by this?
Re: Can somebody give me some hints on how to solve P1056?
Послано Huang SX 8 июн 2004 11:28
How to calculate the maximum path by going up from k
Re: Can somebody give me some hints on how to solve P1056?
Послано Stupnikov Pavel 23 авг 2004 18:52
Just invert directions of all edges and calculate the maximum path by going DOWN form k. Realization of this thing is much easier than its description.
Re: Can somebody give me some hints on how to solve P1056?
Послано Sid 24 июн 2005 11:47
Just cut off leafs of tree step by step while count of nodes >2!


Edited by author 25.06.2005 14:44
Re: Can somebody give me some hints on how to solve P1056?
Послано Mak✭kbtu 12 фев 2010 20:09
Far not the fastest solution, but passed (0.375 sec):
1. make a bidirectional graph, connectivity of which will be kept in an array of vectors
2. start dfs from each of the verticies which are not leaves and calculate the longest path
3. Note that if there are 2 vertices, the answer is always "1 2"
The solution might run in O(N*(N+M)) time, as I guess

Edited by author 15.02.2010 13:13

Edited by author 15.02.2010 13:13