Codeforces Round #418 (Div. 2)D
给n个圆要么包含,要么相分离,没有两个公共点,当成一棵树,把包含的面积大的放在上面

如图最上面的par记为-1,level记为0,当par==-1||level==1时就加否则减,
就是第一,二层先加,第三层减,然后后面的一直交替就行了
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=,inf=; ll x[N],y[N],r[N];
int par[N];
bool level[N];
vector<int>v[N];
void dfs(int i,bool f)
{
level[i]=f;
for(int j=;j<v[i].size();j++)
dfs(v[i][j],f^);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
cout<<setiosflags(ios::fixed)<<setprecision();
int n;
cin>>n;
memset(level,,sizeof level);
memset(par,-,sizeof par);
for(int i=;i<n;i++)cin>>x[i]>>y[i]>>r[i];
for(int i=;i<n;i++)
{
par[i]=-;
for(int j=;j<n;j++)
if(r[j]>r[i]&&(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=(r[i]-r[j])*(r[i]-r[j]))
if(par[i]==-||r[par[i]]>r[j])
par[i]=j;
v[par[i]].push_back(i);
}
for(int i=;i<n;i++)
if(par[i]==-)
dfs(i,);
double ans=0.00;
for(int i=;i<n;i++)
ans+=pi*r[i]*r[i]*(par[i]==-||(level[i]==) ? +:-);
cout<<ans<<endl;
return ;
}
Codeforces Round #418 (Div. 2)D的更多相关文章
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 题意: 给\(n(n <= 1000)\)个圆,圆与圆之间 ...
- Codeforces Round #418 (Div. 2).C two points
C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 m ...
- Codeforces Round #418 (Div. 2)
A: 不细心WA了好多次 题意:给你一个a序列,再给你个b序列,你需要用b序列中的数字去替换a序列中的0,如果能够替换,则需要判断a是否能构成一个非递增的序列,a,b中所有的数字不会重复 思路:就是一 ...
- Codeforces Round #418 (Div. 2) B. An express train to reveries
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- Codeforces Round #418 (Div. 2) A+B+C!
终判才知道自己失了智.本场据说是chinese专场,可是请允许我吐槽一下题意! A. An abandoned sentiment from past shabi贪心手残for循环边界写错了竟然还过了 ...
- Codeforces Round #418 (Div. 2) C
Description Nadeko's birthday is approaching! As she decorated the room for the party, a long garlan ...
- Codeforces Round #418 (Div. 2) B
Description Sengoku still remembers the mysterious "colourful meteoroids" she discovered w ...
- Codeforces Round #418 (Div. 2) A
Description A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight ...
- Codeforces Round #418 (Div. 2) C. An impassioned circulation of affection
C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 m ...
随机推荐
- html5新属性contenteditable 对于那些不可编辑的标签,现在都可以编辑了
contenteditable = true 表示该html标签的内容可以编辑,对于那些不可编辑的标签,现在都可以编辑了.
- Python开发【模块】:time、datatime
时间模块 时间相关的操作,时间有三种表示方式: 时间戳 1970年1月1日之后的秒,即:time.time() 格式化的字符串 2014-11-11 11:11, ...
- Myeclipse 2013 professional 破解
破解前要先关闭Myeclipse2013 1.(1)输入usercode可以随便输入,(2)然后选择Myeclipse的版本,(3)点击systemid按钮 2.然后点击Tools菜单栏下的Rebui ...
- (4.21)SQL Server数据库启动过程(用户数据库加载过程的疑难杂症)
转自:指尖流淌 http://www.cnblogs.com/zhijianliutang/p/4100103.html SQL Server数据库启动过程(用户数据库加载过程的疑难杂症) 前言 本篇 ...
- postman:模拟发送一个需要cookie认证的请求
1.chrome 已安装插件intercept. 由于chrome安全的限制,发不出带cookie的请求.如果想要发送带cookie的请求,需要开启Interceptor. 2.chrome 浏览器要 ...
- C# 反双曲余弦函数
反双曲余弦函数的定义是: T1 = Math.Log(t + Math.Sqrt(t * t - 1)); 1. 叉乘(cross product),也叫向量的外积.向量积.顾名思义,求下来的结果是一 ...
- How To Mine Bitcoins 比特币挖矿
linux 下查看 gpu 的信息: sudo lshw -C display windows下查看cuda信息:In directory C:\Program Files\NVIDIA Corpor ...
- spark mllib和ml类里面的区别
mllib是老的api,里面的模型都是基于RDD的,模型使用的时候api也是有变化的(model这里是naiveBayes), (1:在模型训练的时候是naiveBayes.run(data: RDD ...
- 1 - bootstrap基本模板
bootstrap 3.x 下载地址:http://v3.bootcss.com/ 基本模板如下: <!DOCTYPE html> <html lang="zh-cn&qu ...
- Linux系统——防火墙
防火墙的作用 一种将内部网络和外部网络分开的方法,是一种隔离技术.防火墙在内网与外网通信是进行访问控制,一句锁设置的规则对数据包做出判断,最大限度地阻止网络中的黑客破坏企业网络,从而加强企业网络安全. ...