问题 F: Fences

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

题目描述

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 (��,��)(xi,yi).

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.

输入格式

The first line contains a single integer T (1≤�≤1041T104), denoting the number of test cases.

For each test case, the first line contains two integers �,�n,k (3≤�≤2×1053n2×1051≤�≤�1kn), denoting the number of buildings and the entrance.

Each of the following n lines contains two integers ��,��xi,yi (∣��∣,∣��∣≤106xi,yi106), 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 106106.

输出格式

For each test case, output one real number in a single line denoting the minimum total length of fences. (rounding to 33 decimal places)

输入样例 复制

1
5 3
0 0
0 2
1 1
2 0
2 2

输出样例 复制

8.828