Problem C
Rings
Little John is in big trouble. Playing with his different-sized (and colored!) rings and glue seemed such a good idea... However, the rings now lay on the floor, glued together with something that will definitely not come off with water. Surprisingly enough, it seems like no rings are actually glued to the floor, only to other rings. How about that!
You must help Little John to pick the rings off the floor before his mom comes home from work. Since the glue is dry by now, it seems like an easy enough task. This is not the case. Little John is an irrational kid of numbers, and so he has decided to pick up the largest component (most rings) of glued-together rings first. It is the number of rings in this largest component you are asked to find. Two rings are glued together if and only if they overlap at some point but no rings will ever overlap in only a single point. All rings are of the doughnut kind (with a hole in them). They can however, according to Little John, be considered “infinitely thin”.
Input
Input consists of a number of test cases, at most $20$. Each problem starts with the number of rings, $n$, where $0 \le n < 100$. After that, $n$ rows follow, each containing a ring’s physical attributes. This description consists of $3$ floating point numbers (with at most $3$ decimals), describing the $x$ coordinate and $y$ coordinate for its center, and its radius. Input ends with a single row with the integer $-1$. Coordinates have absolute value at most $100$, and radii are positive and at most $100$.
Output
Output consists of as many answers as there were problems, each answer on a separate line and of the form “The largest component contains $X$ rings.” where $X$ is the number of rings in the largest component. The plural form “rings” is changed to singular if $X = 1$ (see last sample case).
Sample Input 1 | Sample Output 1 |
---|---|
4 0.0 0.0 1.0 -1.5 -1.5 0.5 1.5 1.5 0.5 -2.0 2.0 3.5 3 3.0 2.0 2.0 0.0 -0.5 1.0 0.0 0.0 2.0 5 -2.0 0.0 1.0 1.0 -1.0 1.0 0.0 1.0 0.5 2.0 0.0 1.0 -1.0 1.0 1.0 1 1.0 1.0 1.0 -1 |
The largest component contains 4 rings. The largest component contains 2 rings. The largest component contains 3 rings. The largest component contains 1 ring. |