QOJ.ac

QOJ

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

#1099. American College Test

Statistics

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$.

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.