luogu#P12109. [NWRRC2024] Eight-Shaped Figures
[NWRRC2024] Eight-Shaped Figures
题目背景
Looking at problems K-Shaped Figures
and H-Shaped Figures
from the past two years, you took the warning seriously. You came prepared. For each of the remaining 24 letters of the alphabet, you theorized what the problem could be. You even implemented all 24 solutions and used up all of your Digital Team Reference Document space just to bring these codes to the contest. If the judges are so unoriginal that they set another problem about letter shapes, you'll just get it accepted on minute 1 and leave everyone puzzled.
What, another shapes problem? Really?! Ha-ha! Oh... wait a second...
题目描述
Let's say that two circles on a plane form an if they touch each other, but neither of them lies inside the other one.
You are given a collection of circles on the plane. No two circles have more than one common point. In other words, no two circles intersect twice or coincide, but they can touch or lie one within another.
Find the number of pairs of circles from this collection that form an 8-shaped figure.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer , denoting the number of circles ().
The -th of the following lines contains three integers , , and , denoting the coordinates of the center of the -th circle and its radius (; ). No two circles intersect twice or coincide, but they can touch or lie one within another.
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, print the number of pairs of circles that form an 8-shaped figure.
2
5
1 1 1
1 3 1
3 1 1
3 3 1
6 7 4
6
-3 0 3
-2 0 2
-1 0 1
1 0 1
2 0 2
3 0 3
5
9