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

Discussion of Problem 1987. Nested Segments

If you sort segments according to INCREASING length
Posted by Mahilewets 3 Jul 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
Posted by Hristo Nikolaev (B&W) 13 Apr 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