编程介的小学生 2019-12-02 21:56 采纳率: 20.5%
浏览 110

Find A Way 寻找路线

Problem Description
We'll consider an interesting geometric problem here. Given a number of circles with varying radius on the plane, and define the P-value of a point (x, y) on the plane as the number of circles covering this point. Here, by "covering", we mean that the point is either strictly within the circle, or on the boundary of the circle.
Given the starting position (Sx, Sy), and the destination position (Tx, Ty), please find a path between the two points, such that every point of the path is on the boundary of one or more circles, and the absolute difference between the maximum P-value and the minimum P-value among all points on the path is minimized.
Can you find the minimum absolute value with the help of your computer?

Input
There are multiple test cases in the input file. Each test case starts with one integer N (1 <= N <= 150), the number of circles, followed by four real numbers, Sx, Sy, Tx, Ty, representing the x-coordinate and y-coordinate of the starting position and the destination. Each of the following N lines consists of three real numbers X, Y and R (R >= 1), indicating that there is a circle at position (X, Y) with radius R.
There is a blank line after each test case. Input ends with End-of-File.
Note: It is guaranteed that the input data is always legal, i.e. both the starting position and the destination are on the boundary of one or more circles, no two circles will be at the same position, every real number in the input file has at most three digits after the decimal point, and the absolute value of any real number does not exceed 10000.

Output
For each test case, output one integer on one separate line as requested. If there is no way to reach the destination, output -1 instead.

Sample Input
2
-1.000 0.000 1.000 0.000
0.000 0.000 1.000
1.000 0.000 1.000

2
-1.000 0.000 5.000 0.000
-1.000 -1.000 1.000
4.000 0.000 1.000

Sample Output
Case 1: 1
Case 2: -1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
    • ¥15 Arcgis相交分析无法绘制一个或多个图形
    • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
    • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
    • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
    • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
    • ¥30 3天&7天&&15天&销量如何统计同一行
    • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
    • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型