Photo Op
Farmer John's farm is full of lush vegetation and every cow wants a photo of its natural beauty. Unfortunately, Bessie still has places to be, but she doesn't want to disrupt any photo ops.
Bessie is currently standing at (X,0) on the XY-plane and she wants to get to (0,Y) (1≤X,Y≤106). Unfortunately, N (1≤N≤3⋅105) other cows have decided to pose on the X axis. More specifically, cow i will be positioned at (xi,0) with a photographer at (0,yi) where (1≤xi,yi≤106) ready to take their picture. They will begin posing moments before time si (1≤si<T) and they will keep posing for a very long time (they have to get their picture just right). Here, 1≤T≤N+1.
Bessie knows the schedule for every cow's photo op, and she will take the shortest Euclidean distance to get to her destination, without crossing the line of sight from any photographer to their respective cow (her path will consist of one or more line segments).
If Bessie leaves at time t, she will avoid the line of sights for all photographer/cow pairs that started posing at time si≤t, and let the distance to her final destination be dt. Determine the values of ⌊dt⌋ for each integer t from 0 to T−1 inclusive.
For t=0 the answer is ⌊149⌋=12.
For t=1 the answer is ⌊14+5⌋=16.
For t=5 the answer is ⌊1+92+72+2⌋=14. Path: (8,0)→(9,0)→(0,7)→(0,9)
SCORING:
- Inputs 4-6: N≤100
- Inputs 7-9: N≤3000
- Inputs 10-12: T≤10
- Inputs 13-18: No additional constraints
Problem credits: Suhas Nagar
Source: USA Computing Olympiad.
Input Format
The first line of input contains N and T, representing the number of cows posing on the x-axis and the timeframe that Bessie could leave at.
The second line of input contains X and Y, representing Bessie's starting X coordinate and her target Y coordinate respectively.
The next N lines contain si xi and yi. It is guaranteed that all xi are distinct from each other and X, and all yi are distinct from each other and Y. All si will be given in increasing order, where si≤si+1.
Output Format
Print T lines, with the tth (0-indexed) line containing ⌊dt⌋.