编程介的小学生 2017-04-19 01:59 采纳率: 20.5%
浏览 743
已采纳

Fire Tower

A mountainous region had many forest fires in the dry season of the last year. Prior to the dry season of this year, to watch the forest fire, you are planning to construct a fire tower which enables us to watch all mountain slopes. To minimize the construction cost, you want to minimize the height of the fire tower.

A polyhedral terrain can be thought of as the surface of a mountain range with flat faces and with no curves or overhangs. In this problem, we consider only the 2-dimensional case, which simplifies the polyhedral terrain into a 2-dimensional polygonal chain in the plane. This polygonal chain is represented by n consecutive vertices v1, v2, ..., vn that are given by increasing order of x-coordinate of the vertices and n - 1 edges which connect two adjacent vertices vi and vi + 1 for 1 <= i <= n - 1.

Following figure shows the minimum height fire tower of a polygonal chain.

Your task is to compute the minimum height of the fire tower on a polygonal chain such that every point on the polygonal chain is visible from the top of the fire tower. Note that the fire tower can be placed on a vertex or an edge of the polygonal chain. You can assume that there are no cases where the minimum height of the fire tower is zero.

Input

Your program is to read from standard input. The input consists of Ttest cases. The number of test cases T is given in the first line of the input. Each test case starts with a line containing an integer n, the number of input points, 4 <= n <= 1,000. In the next n lines, the coordinates of a polygonal chain's vertices are given in increasing order of x-coordinate. Each line contains two positive integers x and y that represent the coordinates of the vertex, 0 <= x, y<= 100,000.

Output

Your program is to write to standard output. Print exactly one line for each test case. For each test case, print the minimum height of the fire tower that watches the given polygonal chain with rounded one fractional digit. If the height of the fire tower is greater than 1,000 then print IMPOSSIBLE.

Sample Input

3
12
1 8
3 11
5 1
7 4
9 3
10 1
12 7
14 4
16 3
19 2
20 13
22 12
11
11 9
16 215
21 9
26 215
31 9
36 1
41 9
46 215
51 9
56 215
61 9
8
7 8
12 18
17 8
27 23
37 23
47 8
52 18
57 8
Sample Output
10.5
IMPOSSIBLE
35.0

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面