Guest User

Untitled

a guest
May 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <set>
  5. #include <map>
  6. #include <string>
  7. #include <cmath>
  8. #include <cassert>
  9. #include <ctime>
  10. #include <algorithm>
  11. #include <queue>
  12. #include <memory.h>
  13. #include <stack>
  14.  
  15. using namespace std;
  16.  
  17. #define pb push_back
  18. #define mp make_pair
  19. #define fir first
  20. #define fi first
  21. #define sec second
  22. #define y1 botva23
  23. typedef long long int64;
  24. typedef long double ld;
  25.  
  26. const int inf=2000000000;
  27. const ld eps=1e-07;
  28. const ld pi = 3.1415926535897932384626;
  29.  
  30. int n;
  31. pair <int64, pair <int64, int64> > a[110000];
  32. bool used[110000];
  33.  
  34. bool in(int x, int y) {
  35. if ((a[x].first * a[x].first) >
  36. ((a[x].second.first - a[y].second.first) * (a[x].second.first - a[y].second.first)
  37. + (a[x].second.second - a[y].second.second) * (a[x].second.second - a[y].second.second)))
  38. return true;
  39. return false;
  40. }
  41.  
  42. int main(){
  43. freopen("circles.in","r",stdin);
  44. freopen("circles.out","w",stdout);
  45. scanf("%d", &n);
  46. for (int i = 0; i < n; ++i) {
  47. int x, y, r;
  48. scanf("%d %d %d", &x, &y, &r);
  49. a[i].first = r;
  50. a[i].second.first = x;
  51. a[i].second.second = y;
  52. }
  53. sort(a, a + n);
  54. reverse(a, a + n);
  55. for (int i = 1; i < n; ++i)
  56. if (a[i] == a[i - 1])
  57. used[i] = true;
  58. for (int i = 1; i < n; ++i)
  59. if (in(i - 1, i))
  60. used[i] = true;
  61. ld ans = 0;
  62. for (int i = 0; i < n; ++i)
  63. if (!used[i]) {
  64. ans += pi * ld(a[i].first) * ld(a[i].first);
  65. for (int j = i + 1; j < n; ++j)
  66. if (!used[j] && in(i, j))
  67. used[j] = true;
  68. }
  69. cout.precision(10);
  70. cout << fixed << ans << endl;
  71. return 0;
  72. }
Add Comment
Please, Sign In to add comment