set 维护这些弧就行了

#include <bits/stdc++.h>

#define NS (400005)

using namespace std;

typedef pair<int, int> PII;

template<typename _Tp> inline void IN(_Tp& dig)
{
char c; bool flag = 0; dig = 0;
while (c = getchar(), !isdigit(c)) if (c == '-') flag = 1;
while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
if (flag) dig = -dig;
}

struct circle
{
int x, y, r, u, d;
} P[NS];

int X;

double F(int a, int t)
{
int x = X - P[a].x;
if (!t) t = -1;
return sqrt((double)P[a].r * P[a].r - (double)x * x) * t + P[a].y;
}

struct half
{
int c, t;
bool operator < (const half oth) const
{
double f1 = F(c, t), f2 = F(oth.c, oth.t);
if (fabs(f1 - f2) < 1e-10) return t < oth.t;
return f1 < f2;
}
} Q[NS];

int n, qc, ec, fa[NS], f[NS];

set<half> st;

typedef set<half>::iterator itr;

PII event[NS];

long long ans;

int main(int argc, char const* argv[])
{
IN(n);
for (int i = 1; i <= n; i += 1)
{
IN(P[i].x), IN(P[i].y), IN(P[i].r);
Q[++qc].c = i, Q[qc].t = 1, P[i].u = qc;
Q[++qc].c = i, Q[qc].t = 0, P[i].d = qc;
event[++ec] = PII(P[i].x - P[i].r, i);
event[++ec] = PII(P[i].x + P[i].r, -i);
}
sort(event + 1, event + 1 + ec), f[0] = -1;
for (int i = 1; i <= ec; i += 1)
{
int a = event[i].second;
if (a < 0)
{
X = P[-a].x + P[-a].r;
st.erase(Q[P[-a].u]), st.erase(Q[P[-a].d]);
continue;
}
X = P[a].x - P[a].r;
itr it = st.insert(Q[P[a].u]).first, tmp = it;
if (++tmp != st.end())
{
if (tmp->t) fa[a] = tmp->c;
else fa[a] = fa[tmp->c];
}
else fa[a] = 0;
st.insert(Q[P[a].d]), f[a] = -f[fa[a]];
ans += 1ll * P[a].r * P[a].r * f[a];
}
printf("%lld\n", ans);
return 0;
}


#### Remmina

No puzzle that couldn't be solved.