dfs and similar dp geometry greedy trees *2000

Please click on ads to support us..

C++ Code:

/*************************************************************************
    > File Name: b.cpp
    > Author: Beans
    > Mail: [email protected] 
    > Created Time: 2023/7/7 13:46:51
 ************************************************************************/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define int long long
#define endl '\n'

using namespace std;

const int maxn = 1010;
const double pi = acos(-1.0);

double x[maxn], y[maxn], r[maxn];
int n;

double dis(int i, int j){
	return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

int check(int i, int j){
	return r[i] <= r[j] && dis(i, j) <= r[j] - r[i];
}

int cov[maxn];

signed main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++ ){
		cin >> x[i] >> y[i] >> r[i];
	}
	for(int i = 1; i <= n; i ++ ){
		for(int j = 1; j <= n; j ++ ){
			if(i == j)	continue;
			cov[i] += check(i, j);
		}
	}
	double ans = 0.00000000;
	for(int i = 1; i <= n; i ++ ){
		if(!cov[i] || cov[i] & 1)	ans += pi * r[i] * r[i] * 1.00000000;
		else	ans -= pi * r[i] * r[i] * 1.00000000;
	}
	cout << fixed << setprecision(8) << ans << endl;
}

	 	  		   			 	  				 	    		


Comments

Submit
0 Comments
More Questions

933A - A Twisty Movement
1722F - L-shapes
1196B - Odd Sum Segments
1325D - Ehab the Xorcist
552B - Vanya and Books
1722E - Counting Rectangles
168A - Wizards and Demonstration
168B - Wizards and Minimal Spell
7A - Kalevitch and Chess
912B - New Year's Eve
1537C - Challenging Cliffs
879B - Table Tennis
1674E - Breaking the Wall
1282A - Temporarily unavailable
1366C - Palindromic Paths
336A - Vasily the Bear and Triangle
926A - 2-3-numbers
276D - Little Girl and Maximum XOR
1253C - Sweets Eating
1047A - Little C Loves 3 I
758D - Ability To Convert
733A - Grasshopper And the String
216A - Tiling with Hexagons
1351B - Square
1225A - Forgetting Things
1717A - Madoka and Strange Thoughts
1717B - Madoka and Underground Competitions
61B - Hard Work
959B - Mahmoud and Ehab and the message
802G - Fake News (easy)