aboutsummaryrefslogtreecommitdiff
path: root/c/las12uvas/2019/543_tensionEnLasPlayas.cpp
blob: aa89fdefc2f8d8fa6baa63df61c6ac863631ee53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>

int compara(int x1, int y1, int r1,
		int x2, int y2, int r2)
{
	int distSq = (x1 - x2) * (x1 - x2) +
		(y1 - y2) * (y1 - y2);
	int radSumSq = (r1 + r2) * (r1 + r2);
	if (distSq >= radSumSq)
		return 0;
	return 1;
}

int caso() {
	int sombrillas;
	int i, j;
	int solapes = 0;

	std::cin >> sombrillas;
	int xs[sombrillas];
	int ys[sombrillas];
	int rs[sombrillas];
	for (i = 0; i < sombrillas; i++) {
		std::cin >> xs[i];
		std::cin >> ys[i];
		std::cin >> rs[i];
	}
	if (sombrillas < 2) {
		return 0;
	}
	for (i = 0; i < sombrillas-1; i++) {
		for (j = i+1; j < sombrillas; j++) {
			if (compara(xs[i], ys[i], rs[i], xs[j], ys[j], rs[j]))
				solapes++;
		}
	}
	return solapes;
}

int main() {
	int casos;
	for (std::cin >> casos; casos > 0; casos--) {
		std::cout << caso() << std::endl;
	}
	return 0;
}