|
||||||||||
FencesTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 76 Accepted Submission(s): 26 Problem Description A village consists of $n$ buildings. Each building can be represented as a point on a two-dimensional plane. The coordinates of building $i$ are $(x_i,y_i)$. The villagers want to put up fences around the village with the following requirements: - Fences must form a simple polygon; - Every building is in the polygon (including borders); - Building $k$, as the entrance of the village, must lie on the fences. Find the minimum total length of fences required to form a valid polygon. Input The first line contains a single integer $T$ ($1\le T\le 10^4$), denoting the number of test cases. For each test case, the first line contains two integers $n, k$ ($3\le n\le 2\times 10^5$, $1\le k\le n$), denoting the number of buildings and the entrance. Each of the following $n$ lines contains two integers $x_i,y_i$ ($|x_i|,|y_i|\le 10^6$), denoting the coordinates of building $i$. For each test case, it is guaranteed that the given points are distinct, and there are at least three points that are not collinear. It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$. Output For each test case, output one real number in a single line denoting the minimum total length of fences. (rounding to $3$ decimal places) Sample Input
Sample Output
Source | ||||||||||
|