给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. SaltStack生产案例-服务部署(redis,mysql,apache+php,haproxy+keepalived)

    顺序代码资料链接 课上资料.zip 接上篇:SaltStack生产案例-系统初始化 1,redis 主从 2,mysql 主从 2.1 mysql-install.sls (安装 初始化) 2.2   ...

  2. Eclipse Tomcat插件的配置, 及 Tomcat 的配置

    Eclipse Tomcat插件的配置, 及 Tomcat 的配置   首先下载 对应 eclipse 版本的 tomcat 插件版本,(这里要注意: Tomcat 插件是Tomcat 插件,Tomc ...

  3. CentOS下LVM逻辑卷管理技术解释

    1.LVM逻辑卷管理技术产生的背景 企业日益变化的存储需要使得传统的磁盘分区存储显得不够灵活 2.磁盘分区存储 对于这样的三个物理分区的话,迟早有一天会被数据填满,因为它是死的,无法进行缩放. 假设下 ...

  4. iptables,lokkit,ebtables,arptables---logrotate

    iptables,lokkit,ebtables,arptables logrotate  这五个位置也被称为五个钩子函数(hook functions),也叫五个规则链. 1.PREROUTING ...

  5. F(N)---hdu2802(寻找循环节)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2802 f[1] = 1; f[2] = 7; f[n] = (f[n-2] - (n-1)*(n-1) ...

  6. Oil Skimming---hdu4185(最大匹配)

    题目链接 题意:有一个地图.代表水#代表油每个单元格是10*10的,现有10*20的勺子可以提取出水上漂浮的油,问最多可以提取几勺的油: 每次提取的时候勺子放的位置都要是油,不然就被污染而没有价值了: ...

  7. Python开发【Django】:Model操作(一)

    Django ORM基本配置 到目前为止,当我们的程序涉及到数据库相关操作时,我们一般都会这么搞: 创建数据库,设计表结构和字段 使用 MySQLdb 来连接数据库,并编写数据访问层代码 业务逻辑层去 ...

  8. Magento 2 初探

    进入公司有一小段时间了,虽然自己之前一直从事前端工作,但是基本工作就是做一些国内电商网站的前端工作.在刚进入这家公司时,自己对 magento2 一无所知,尽管上班前看过老大发给我的一些文档资料,但是 ...

  9. 小米范工具系列之四:小米范HTTP批量发包器

    最新版本1.3,下载地址:http://pan.baidu.com/s/1c1NDSVe  文件名httpsender . 此工具使用java 1.8以上版本运行. 小米范HTTP批量发包器的主要功能 ...

  10. Linux下编译安装PHP扩展memcached

    [安装 libevent] $ tar zxvf libevent-2.0.20-stable.tar.gz $ cd libevent-2.0.20-stable/$ ./configure --p ...