2062: [USACO 2025 January Contest, Gold] Problem 3. 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 on the XY-plane and she wants to get to ( ). Unfortunately, ( ) other cows have decided to pose on the axis. More specifically, cow will be positioned at with a photographer at where ready to take their picture. They will begin posing moments before time ( ) and they will keep posing for a very long time (they have to get their picture just right). Here, .
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 , she will avoid the line of sights for all photographer/cow pairs that started posing at time , and let the distance to her final destination be . Determine the values of for each integer from to inclusive.
输入
The second line of input contains and , representing Bessie's starting coordinate and her target coordinate respectively.
The next lines contain and . It is guaranteed that all are distinct from each other and , and all are distinct from each other and . All will be given in increasing order, where .
输出
样例输入
4 5
6 7
1 7 5
2 4 4
3 1 6
4 2 9
样例输出
9
9
9
10
12
提示
SAMPLE INPUT:
2 3
10 7
1 2 10
1 9 1
SAMPLE OUTPUT:
12
16
16
For the answer is ⌊√149⌋= 12
For the answer is .
SAMPLE INPUT:
5 6
8 9
1 3 5
1 4 1
3 10 7
4 9 2
5 6 6
SAMPLE OUTPUT:
1212
12
12
14
14