给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的更多相关文章

  1. 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)\)个圆,圆与圆之间 ...

  2. 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 ...

  3. Codeforces Round #418 (Div. 2)

    A: 不细心WA了好多次 题意:给你一个a序列,再给你个b序列,你需要用b序列中的数字去替换a序列中的0,如果能够替换,则需要判断a是否能构成一个非递增的序列,a,b中所有的数字不会重复 思路:就是一 ...

  4. 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 ...

  5. Codeforces Round #418 (Div. 2) A+B+C!

    终判才知道自己失了智.本场据说是chinese专场,可是请允许我吐槽一下题意! A. An abandoned sentiment from past shabi贪心手残for循环边界写错了竟然还过了 ...

  6. Codeforces Round #418 (Div. 2) C

    Description Nadeko's birthday is approaching! As she decorated the room for the party, a long garlan ...

  7. Codeforces Round #418 (Div. 2) B

    Description Sengoku still remembers the mysterious "colourful meteoroids" she discovered w ...

  8. Codeforces Round #418 (Div. 2) A

    Description A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight ...

  9. 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 ...

随机推荐

  1. 数据字典Data Dict

    数据字典 所有的数据表都属于数据库对象,每当创建一张数据表的时候,会自动在指定的数据字典表执行一个增加语句(这个增加语言我们是不知道的),数据字典的数据操作只能通过命令完成,不能直接使用SQL完成. ...

  2. Webservice实践(七)CXF 与Spring结合+tomcat发布

    上一节介绍了如何使用CXF 来发布服务,但是没有介绍使用web 容器来发布,很多项目需要用tomcat 这样的容器来发布.另外本节将介绍CXF 与spring 结合的方法. 一 目标: 1.利用spi ...

  3. Oracle系统结构之修改oracle内存参数

    Linux主机16g内存,修改oracle数据库内存参数: 1.编辑/etc/fstab文件:针对tmpfs行将defaults改成defaults,size=12g(千万注意格式,不能出现错误) 修 ...

  4. 新一代Java模板引擎Thymeleaf

    新一代Java模板引擎Thymeleaf-spring,thymeleaf,springboot,java 相关文章-天码营 https://www.tianmaying.com/tutorial/u ...

  5. Python 读取写入配置文件 —— ConfigParser

    Python 读取写入配置文件 —— ConfigParser Python 读取写入配置文件很方便,可使用内置的 configparser 模块:可查看源码,如博主本机地址: “C:/python2 ...

  6. Struts,Spring,Hibernate优缺点

    Struts跟Tomcat.Turbine等诸 多Apache项目一样,是开源软件,这是它的一大优点.使开发者能更深入的了解其内部实现机制. Struts开放源码框架的创建是为了使开发者在构建基于Ja ...

  7. 102-advanced-代码分割

    1.Bundling 大多数React应用程序将使用Webpack或Browserify等工具“捆绑”文件.捆绑是跟踪导入的文件并将它们合并到单个文件中的过程:“捆绑”.然后,该包可以包含在网页中以一 ...

  8. 二、 Mosquitto 使用说明

    一. 继上一篇文章<<Mosquitto 介绍&安装>> 之后.本章介绍 Mosquitto 的 简单使用. 1> 创建用户 # groupadd mosquit ...

  9. 3.1 Templates -- Handlerbars Basics(Handlerbars基础知识)

    一.简介 Ember.js使用Handlerbars模板库来强化应用程序的用户界面.它就像普通的HTML,但也给你嵌入表达式去改变现实的内容. Ember使用Handlerbars并且用许多新特性去扩 ...

  10. 安装完C++builder6.0启动的时候总是出现无法将'C:\Program Files\Borland\CBuilder6\Bin\bcb.$$$'重命名为bcb.dro

    :兼容性问题  运行前右键属性“兼容性”-尝试不同的兼容性.比如“windows 8”