Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <set>
- #include <map>
- #include <string>
- #include <cmath>
- #include <cassert>
- #include <ctime>
- #include <algorithm>
- #include <queue>
- #include <memory.h>
- #include <stack>
- using namespace std;
- #define pb push_back
- #define mp make_pair
- #define fir first
- #define fi first
- #define sec second
- #define y1 botva23
- typedef long long int64;
- typedef long double ld;
- const int inf=2000000000;
- const ld eps=1e-07;
- const ld pi = 3.1415926535897932384626;
- int n;
- pair <int64, pair <int64, int64> > a[110000];
- bool used[110000];
- bool in(int x, int y) {
- if ((a[x].first * a[x].first) >
- ((a[x].second.first - a[y].second.first) * (a[x].second.first - a[y].second.first)
- + (a[x].second.second - a[y].second.second) * (a[x].second.second - a[y].second.second)))
- return true;
- return false;
- }
- int main(){
- freopen("circles.in","r",stdin);
- freopen("circles.out","w",stdout);
- scanf("%d", &n);
- for (int i = 0; i < n; ++i) {
- int x, y, r;
- scanf("%d %d %d", &x, &y, &r);
- a[i].first = r;
- a[i].second.first = x;
- a[i].second.second = y;
- }
- sort(a, a + n);
- reverse(a, a + n);
- for (int i = 1; i < n; ++i)
- if (a[i] == a[i - 1])
- used[i] = true;
- for (int i = 1; i < n; ++i)
- if (in(i - 1, i))
- used[i] = true;
- ld ans = 0;
- for (int i = 0; i < n; ++i)
- if (!used[i]) {
- ans += pi * ld(a[i].first) * ld(a[i].first);
- for (int j = i + 1; j < n; ++j)
- if (!used[j] && in(i, j))
- used[j] = true;
- }
- cout.precision(10);
- cout << fixed << ans << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment