F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Fences

Time 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
1 5 3 0 0 0 2 1 1 2 0 2 2
 

Sample Output
8.828
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 17:20:39, Gzip enabled