QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#1099. American College Test

统计

For a region $S$ in a two-dimensional plane, the convex hull is defined as:

$$C(S) = \{p | \exists \alpha \in [0,1], \exists p_1, p_2 \in S, p = \alpha p_1 + (1-\alpha) p_2\}$$

Given $n$ circles $C_1, \ldots, C_n$, let $S = \bigcup_{i=1}^n C_i$, which is the union of all circles. Your task is to find the perimeter of the convex hull $C(C(S))$.

Input Format

  • The first line contains an integer $T (1 \leq T \leq 60)$, representing the number of test cases.
  • For each test case:
    • The first line contains a positive integer $n$ indicating the number of circles.
    • The following $n$ lines contain three integers $x_i, y_i, r_i(1 \leq r_i \leq 1000, |x_i|, |y_i| \leq 10^3)$, describing a circle.

Output Format

  • For each test case, output a single line with a floating-point number representing the perimeter of the convex hull. Your answer will be considered correct if the absolute or relative error does not exceed $10^{-6}$.

Sample

Sample Input

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

Sample Output

8.28318530718
10.28318530718
14.28318530718

Constraints

  • For $20\%$ of the data, $n \leq 2$.
  • For $50\%$ of the data, $n \leq 3$.
  • For $70\%$ of the data, $n \leq 5$.
  • For $100\%$ of the data, $n \leq 100$.
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.