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

Обсуждение задачи 1699. Черепахи и повороты

Vlad Hint for solution [5] // Задача 1699. Черепахи и повороты 14 мар 2009 18:08
This was overall a great problems set!

Can anyone give a hint on the solution for "J. Turning Turtles"?
What special property (beside that it's a tree) must one use?
What is the complexity of the intended solution?

Thanks in advance!
Samsonov Alex [USU] Re: Hint for solution [2] // Задача 1699. Черепахи и повороты 14 мар 2009 20:19
This problem can be solved in O(N + Q*logN), where N is the size of the field.
Vedernikoff Sergey (HSE: EconomicsForever!) Re: Hint for solution [1] // Задача 1699. Черепахи и повороты 14 мар 2009 21:43
Am I right that we build slightly another tree and then use LCA on that? =)
And when the problems will be added to the problemset?
Samsonov Alex [USU] Re: Hint for solution // Задача 1699. Черепахи и повороты 14 мар 2009 23:27
Actually it is possible to use the given tree. But calculating the answer is not very trivial.
svr Re: Hint for solution [1] // Задача 1699. Черепахи и повороты 14 ноя 2009 11:30
I was glad to use successfully LCA
with forgotten implementation.
It is enough to know what LCA do.
It is mean that LCA very adequate tool for tree
and cannot be omitted in learning.
Harkonnen Re: Hint for solution // Задача 1699. Черепахи и повороты 17 авг 2022 10:36
It is possible to use given tree, but my complexity is O(N*log(N)+Q*log(N)) - 0.25 sec and quite a bunch of RAM. For every node store its 1st, 2nd, 4th, 8th, 16th, ... 2^16th parent. Also store number of turns on that path and final orientation after last move (horizontal/vertical). This information is enough to calculate answers at log(N).