1997. Secret Operation

单点时限: 10.0 sec

内存限制: 256 MB

Mary Ice is a member of a spy group. She is about to carry out a secret operation with her colleague.

She has got into a target place just now, but unfortunately the colleague has not reached there yet. She needs to hide from her enemy George Water until the colleague comes. Mary may want to make herself appear in George’s sight as short as possible, so she will give less chance for George to find her.

You are requested to write a program that calculates the time Mary is in George’s sight before her colleague arrives, given the information about moves of Mary and George as well as obstacles blocking their sight.

Read the Input section for the details of the situation.

输入格式

The input has the following format:

The first line contains two integers. () is the time Mary’s colleague reaches the place. () is the distance George can see – he has a sight of this distance and of 45 degrees left and right from the direction he is moving. In other words, Mary is found by him if and only if she is within this distance from him and in the direction different by not greater than 45 degrees from his moving direction and there is no obstacles between them.

The description of Mary’s move follows. Mary moves from (, ) to (, ) straight and at a constant speed during the time between and , for each .

The following constraints apply: , and , and < for any . The description of George’s move is given in the same way with the same constraints, following Mary’s. In addition, and do not coincide for any . In other words, George is always moving in some direction.

Finally, there comes the information of the obstacles. Each obstacle has a rectangular shape occupying to . No obstacle touches or crosses with another. The number of obstacles ranges from to inclusive.

All the coordinates are integers not greater than in their absolute values. You may assume that, if the coordinates of Mary’s and George’s moves would be changed within the distance of , the solution would be changed by not greater than .

输出格式

Print the calculated time in a line. The time may be printed with any number of digits after the decimal point, but should be accurate to .

样例

Input
50 100
2
50 50 0
51 51 50
2
0 0 0
1 1 50
0
Output
50

0 人解决,1 人已尝试。

0 份提交通过,共有 1 份提交。

9.9 EMB 奖励。

创建: 9 年,8 月前.

修改: 2 年前.

最后提交: 4 年,3 月前.

来源: Japan

题目标签