#K12791. Three Safe Treasure Collection
Three Safe Treasure Collection
Three Safe Treasure Collection
Charlotte is on a quest to collect exactly three treasures. Each treasure is guarded by a magnetic field that forms a circle with a given center \((x, y)\) and radius \(r\). The magnetic fields of the treasures must not overlap; formally, for any two selected treasures with centers \((x_1, y_1)\) and \((x_2, y_2)\) and radii \(r_1\) and \(r_2\), the fields are considered separate if
[ (x_1 - x_2)^2 + (y_1 - y_2)^2 \ge (r_1 + r_2)^2 ]
Your task is to determine whether there exists a set of three treasures satisfying the above condition. If such a combination exists, print the coordinates (formatted as (x, y)
) of each treasure in lexicographical order. Otherwise, output the message "Charlotte cannot collect three treasures."
inputFormat
The input is read from standard input (stdin
) and is formatted as follows:
- The first line contains an integer \(n\) representing the number of treasures.
- The next \(n\) lines each contain three integers \(x\), \(y\), and \(r\) separated by spaces, where \((x, y)\) is the coordinate of a treasure and \(r\) is the radius of its magnetic field.
outputFormat
Output is written to standard output (stdout
). If there exists a valid combination, print three lines, each line showing the coordinate of a treasure in the format (x, y)
. If no valid combination exists, print a single line with the text "Charlotte cannot collect three treasures."
5
100 100 50
800 800 40
1500 1500 60
300 300 30
1200 1200 50
(100, 100)
(300, 300)
(800, 800)
</p>