define _CRT_SECURE_NO_WARNI NGS include iostream include cstdio includ

 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cassert>
#define inf 1e14
#define eps 1e-8
#define EPS 1e-4
using namespace std;
struct v2 {
double x, y;
v2() {}
v2(double x, double y) : x(x), y(y) {}
v2 operator - (const v2 &a) const { return v2(x - a.x, y - a.y); }
bool operator < (const v2 &a) const { return y < a.y; }
};
struct p {
double y;
int c;
p() {}
p(double x, int y) : y(x), c(y) {}
bool operator < (const p &a) const { return y < a.y; }
};
vector<double> r;
vector<v2> g;
int n;
double f(double x) {
vector <p> k;
for (int i = 0; i < n; ++i) {
double X = abs(g[i].x - x);
if (X < r[i] + eps) {
k.push_back(p(g[i].y - sqrt(r[i] * r[i] - X * X), 1));
k.push_back(p(g[i].y + sqrt(r[i] * r[i] - X * X), -1));
}
}
sort(k.begin(), k.end());
double ans(0), cur(0);
int rang(0), in(0);
for (int i = 0; i < k.size(); ++i) {
if (in == 0) {
cur = i;
in = 1;
}
rang += k[i].c;
if (rang == 0) {
ans += k[i].y - k[cur].y;
in = 0;
}
}
return ans;
}
int main() {
//freopen("input.txt", "r", stdin);
cin >> n;
r.resize(n);
g.resize(n);
for (int i = 0; i < n; ++i)
cin >> g[i].x >> g[i].y >> r[i];
return 0;
}