2062: [USACO 2025 January Contest, Gold] Problem 3. Photo Op

文件提交:无需freopen 内存限制:256 MB 时间限制:16.000 S
评测方式:普通裁判 命题人:
提交:2 解决:1

题目描述

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 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  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 .

输出

Print T lines, with the th (0-indexed) line containing .

样例输入

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:

12

12

12

12

14

14

 the answer is . Path: 

  • Inputs 7-9: 
  • Inputs 10-12: 
  • Inputs 13-18: No additional constraints

来源/分类