#K12071. Non-overlapping Circles

    ID: 23609 Type: Default 1000ms 256MiB

Non-overlapping Circles

Non-overlapping Circles

In this problem, you are given N circles, each defined by its center coordinates (x, y) and radius r. Your task is to determine whether no two circles overlap. Two circles are considered non-overlapping if the distance between their centers is at least the sum of their radii. Otherwise, they are overlapping.

More formally, for any two circles i and j, let the distance between their centers be defined as [ d_{ij} = \sqrt{(x_i - x_j)^2 + (y_i - y_j)^2} ] The circles do not overlap if [ d_{ij} \geq r_i + r_j ]

If all pairs of circles satisfy the above condition, output "YES"; otherwise output "NO".

This problem tests your ability to work with geometric calculations and handling multiple test cases using standard input and output.

inputFormat

The input consists of multiple lines:

  • The first line contains an integer N, representing the number of circles.
  • Each of the next N lines contains three integers x, y, and r, representing the center coordinates and radius of a circle.

It is guaranteed that N (1 ≤ N ≤ 10^5) and the values of x, y, r are such that all calculations fit into standard data types.

outputFormat

Output a single line containing "YES" if no two circles overlap, otherwise output "NO". An overlap is defined when the Euclidean distance between two circle centers is strictly less than the sum of their radii.## sample

3
0 0 1
3 3 1
6 0 1
YES