Gửi bài giải

Điểm: 1,74 (OI)
Giới hạn thời gian: 3.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Khuc Anh Tuan - ACM Vietnam Practice
Dạng bài
Ngôn ngữ cho phép
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

You are given three triangle houses. Each house is presented by three points in the 2D coordination. Houses are not overlap but can share points on their border.

You stay at point ~(s_x, s_y)~ and want to reach ~(e_x, e_y)~ by ~a~ shortest path. Your path can not intersect with ~a~ house but you can go ~a~ long ~a~ house's border. However, you can not "go through" the walls as follow (just an example, please use natural meaning):

image

You are to write a program to print the length of the shortest path.

Input

The input begins with ~T~ -- number of test cases. For each test case:

  • The first line of each test case consists of ~s_x, s_y, e_x, e_y~.
  • In next three lines, each line consists of ~6~ numbers ~x_1~, ~y_1~, ~x_2~, ~y_2~, ~x_3~, ~y_3~ denote coordinates of ~a~ house.

Output

For each test case, print the length of the shortest path with exactly ~5~ precision digits.

Giới hạn

  • ~T \le 20~
  • The absolute values of coordinates are less than ~1000~.

Sample Input

1
0 0 3 0
1 0 2 0 1 1
2 0 2 -1 3 -1
2 1 3 1 2 2

Sample Output

3.65028

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.