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

Обсуждение задачи 1987. Вложенные отрезки

If you sort segments according to INCREASING length
Послано Mahilewets 3 июл 2017 22:47
If you sort segments according to INCREASING length.  Then you can consider all segments one by one consecutively.  Find points belong to the current segment.  For those points current segment is the answer.
Because of the segments are sorted.
Re: If you sort segments according to INCREASING length
Послано Hristo Nikolaev (B&W) 13 апр 2023 23:54
From all suggested hints, this is the fastest way to do it.
Initially I tried with trees, but I was getting TLE on #13.
Finally I decided to use a map for the points (with key=point, value=index)
It's a very convenient Data Structure, because it provides fast search for the nearest value (lower bound), and allows you to delete that point once its segment has been found.
I tried without deleting it, but got TLE #14.
Deleting each point from the map after finding it makes the map smaller after each iteration.

Finally got an AC in 0.1