8595: Check In

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:0

题目描述

One day, NIO overslept because of the over-time working last night. Coincidentally, the company's new check-in system went live. As soon as one arrives at anywhere of a building, he/she can open the check-in app and sign in, instead of checking in at a specific card machine. In order not to be late, NIO prepared to walk straightly to his company. He may walk through several buildings, but not get strictly inside them. Suppose all the buildings are in the shape of a non-degenerated triangle, and NIO's starting point is the origin point. Can NIO walk in a straight line to his company without walking in other buildings? And if so, tell him the minimum distance he needs to walk.

输入格式

For each case, the first line is an integer n (2≤n≤1000), representing the number of buildings on the map.
Then n lines follow, each line contains six integers xi1,yi1,xi2,yi2,xi3,yi3(−10000≤xi1,yi1,xi2,yi2,xi3,yi3≤10000), representing the location of the three vertex of the i-th building. The first building is NIO's company, and the rest n−1 lines denotes other buildings.

输出格式

If NIO can walk directly to his company, output a number denoting the minimum distance he should walk. Otherwise output −1.

Your answer is acceptable if its absolute or relative error does not exceed 10−6.

输入样例 复制

2
1 1 1 2 2 1
1 3 3 3 3 1

输出样例 复制

1.414213562

数据范围与提示

It is guaranteed that the starting point is not strictly inside any buildings, and no two buildings share a region of non-zero area.