structData { double x; int c; Data(double x = 0, int c = 0) : x(x), c(c) {} inlinebooloperator<(const Data &a) const { return x < a.x; } };
structTask { int n; double ans; Circle a[MAXN + 2]; Data pos[MAXN * 2 + 4];
inlinedoublesolve(int c){ registerint tot = 0, cnt = 0; for (registerint i = 1; i <= n; i++) { if (i != c) { Point d = a[i].o - a[c].o; registerdouble dis = d.len(); if (a[c].r <= a[i].r - dis) return0; if (a[i].r <= a[c].r - dis || a[i].r + a[c].r <= dis) continue; registerdouble beta = atan2(d.y, d.x); registerdouble alpha = acos((dis * dis + a[c].r * a[c].r - a[i].r * a[i].r) / (2 * dis * a[c].r)); registerdouble theta2 = beta - alpha, theta1 = beta + alpha; if (theta2 < -PI) theta2 += PI2; if (theta1 >= PI) theta1 -= PI2; if (theta2 > theta1) cnt++; pos[++tot] = Data(theta2, 1); pos[++tot] = Data(theta1, -1); } } pos[0].x = -PI, pos[++tot].x = PI; std::sort(pos + 1, pos + 1 + tot); registerdouble ans = 0; for (registerint i = 1; i <= tot; cnt += pos[i++].c) if (cnt == 0) ans += a[c].calc(pos[i - 1].x, pos[i].x); return ans; }
inlinevoidsolve(){ IO::read(n); for (registerint i = 1; i <= n; i++) a[i].read(); std::sort(a + 1, a + 1 + n); n = std::unique(a + 1, a + 1 + n) - a - 1; for (registerint i = 1; i <= n; i++) ans += solve(i); printf("%.3f\n", ans / 2); } } task; }