Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2015. október 21.

October 21, 2015 10:00 AM – October 21, 2015 3:00 PM

Rings and Glue

Little John is in big trouble. Playing with his rings of different sizes (and colors!) 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 Specification

The input consists of a number (> 0) of problems. Each problem starts with the number of rings, n, where 0 ≤ n < 100. After that, n rows follow, each containing a ring's physical attributes. That is, 3 floating point numbers, with an arbitrary number of spaces between them, describing the x-coordinate and y-coordinate of its center and its radius. All floating point numbers fit into the standard floating point type of your favorite programming language (e.g., float for C/C++). The input ends with a line with the single integer –1.

Output Specification

The output consists of as many grammatically correct answers as many problems there were, each answer, on a separate line, being “The largest component contains X ring(s).”, where X is the number of rings in the largest component. (The last word should be “ring” if X = 1, and “rings” otherwise.)

Sample Input

  1. 4
  2. 0.0 0.0 1.0
  3. -1.5 -1.5 0.5
  4. 1.5 1.5 0.5
  5. -2.0 2.0 3.5
  6. 3
  7. 3.0 2.0 2.0
  8. 0.0 -0.5 1.0
  9. 0.0 0.0 2.0
  10. 5
  11. -2.0 0.0 1.0
  12. 1.0 -1.0 1.0
  13. 0.0 1.0 0.5
  14. 2.0 0.0 1.0
  15. -1.0 1.0 1.0
  16. -1
download as text file

Output for Sample Input

  1. The largest component contains 4 rings.
  2. The largest component contains 2 rings.
  3. The largest component contains 3 rings.
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019