-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoj1202.cpp
More file actions
83 lines (74 loc) · 1.81 KB
/
aoj1202.cpp
File metadata and controls
83 lines (74 loc) · 1.81 KB
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
77
78
79
80
81
82
83
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
void area(double bx, double by, double ux, double uy, bool b[201][201]) {
FOR(i, bx, ux)
FOR(j, by, uy)
b[i][j] = true;
return;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, cnt = 1;
while(cin >> n, n) {
vector<double> x, y, bx, by, ux, uy;
REP(i, n) {
double x2, y2, r;
cin >> x2 >> y2 >> r;
x.pb(x2-r); x.pb(x2+r);
y.pb(y2-r); y.pb(y2+r);
bx.pb(x2-r); by.pb(y2-r);
ux.pb(x2+r); uy.pb(y2+r);
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
x.erase(unique(x.begin(), x.end()), x.end());
y.erase(unique(y.begin(), y.end()), y.end());
REP(i, n) {
bx[i] = find(x.begin(), x.end(), bx[i]) - x.begin();
by[i] = find(y.begin(), y.end(), by[i]) - y.begin();
ux[i] = find(x.begin(), x.end(), ux[i]) - x.begin();
uy[i] = find(y.begin(), y.end(), uy[i]) - y.begin();
}
bool b[201][201] = {};
REP(i, n)
area(bx[i], by[i], ux[i], uy[i], b);
double sum = 0;
REP(i, x.size()) REP(j, y.size())
if(b[i][j])
sum += (x[i+1] - x[i]) * (y[j+1] - y[j]);
cout << fixed << setprecision(2) << cnt << ' ' << sum << endl;
cnt++;
}
return 0;
}