地址:http://acm.swust.edu.cn/oj/problem/1025/
TT lives in a dream world.All countries in the world are circular or rectangular.There is a moat on the territorial border of each country.(the edge of the circle or the rectangle).The water in the moat flow in one direction,so people in the country can travel in the moat by ship.
Now there are N countries numbered 1,2,3……N.TT is in the moat of the country numbered 1.He wants to get to the country numbered N.(get to the country's moat)How much distance does TT have to walk(not by ship) at least?
InputThe input consists of multiple test cases.
For each case,the first line contains one integer N(2<=N<=200),the number of countries in this world,then N lines follow,the ith line indicates the information of the country numbered i.Here is the detail:
C X Y R:indicate the country numbered i is a circle,and the center of the circle is(X,Y),the radius is R.(0<=R<=10^6)
R X1 Y1 X2 Y2(X1!=X2,Y1!=Y2):indicate the country numbered i is a rectangle,and the two vertexs of one diagonal are (X1,Y1) and (X2,Y2). (-10^6 We guarantee that any two countries don't overlap. The input terminates with the integer 0. The minimum distance TT has to walk.Please keep two decimal places. 求点1到点n的最短距离,保留2位小数,这部分很裸的最短路 关键是把边的距离求出来,它的点是圆或者矩形(无重叠),要求出两个图形的最短距离. 圆和圆的距离就是圆心距减去半径和 圆到矩形的距离,可以把矩形看成4条线段,也就是圆心到线段的距离 矩形到矩形的距离,分别看成4条线段.... Sample Input
2
C 0 0 1
R 1 5 2 6
3
C 0 0 1
C 2 2 1
R 3 0 4 1
0
Sample Output
4.10
1.24
由于OJ上传数据的BUG,换行请使用"\r\n",非常抱歉
Source
#include