大意: 给定n个不相交的圆, 求将n个圆划分成两部分, 使得阴影部分面积最大.

贪心, 考虑每个连通块, 最外层大圆分成一部分, 剩余分成一部分一定最优.

#include <iostream>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head const int N = 1e6+10;
int n, deg[N];
struct {int x,y,r;} a[N];
ll sqr(int x) {return (ll)x*x;}
const double pi = acos(-1); int main() {
scanf("%d", &n);
REP(i,1,n) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].r);
REP(i,1,n) REP(j,1,i-1) {
double d = sqrt(sqr(a[i].x-a[j].x)+sqr(a[i].y-a[j].y));
double dd = abs(a[i].r-a[j].r);
if (d<=dd) ++deg[a[i].r<a[j].r?i:j];
}
double ans = 0;
REP(i,1,n) {
if (!deg[i]||(deg[i]&1)) ans+=pi*sqr(a[i].r);
else ans-=pi*sqr(a[i].r);
}
printf("%.12lf\n", ans);
}

An overnight dance in discotheque CodeForces - 814D (几何)的更多相关文章

  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. An overnight dance in discotheque

    An overnight dance in discotheque time limit per test 2 seconds memory limit per test 256 megabytes ...

  3. CodeForces 814D An overnight dance in discotheque(贪心+dfs)

    The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spac ...

  4. codeforces 814D An overnight dance in discotheque

    题目链接 正解:贪心. 首先我们可以计算出每个圆被多少个圆覆盖. 很显然,最外面的圆是肯定要加上的. 然后第二层的圆也是要加上的.那么第三层就不可能被加上了.同理,第四层的圆又一定会被加上. 然后我们 ...

  5. codeforces 814 D. An overnight dance in discotheque (贪心+bfs)

    题目链接:http://codeforces.com/contest/814/problem/D 题意:给出奇数个舞者,每个舞者都有中心坐标和行动半径,而且这些点组成的园要么相互包含要么没有交集求,讲 ...

  6. CF#418 Div2 D. An overnight dance in discotheque

    一道树形dp裸体,自惭形秽没有想到 首先由于两两圆不能相交(可以相切)就决定了一个圆和外面一个圆的包含关系 又可以发现这样的树中,奇数深度的圆+S,偶数深度的圆-S 就可以用树形dp 我又写挫了= = ...

  7. [CodeForces]CodeForces 13D 几何 思维

    大致题意: 给出N个红点和M个蓝点,问可以有多少个红点构成的三角形,其内部不含有蓝点 假设我们现在枚举了一条线段(p[i],p[j]),我们可以记录线段下方满足(min(p[i].x,p[j].x)& ...

  8. Codeforces 814D

    题意略. 思路: 由于不重合这个性质,我们可以将每一个堆叠的圆圈单独拿出来考虑,而不用去考虑其他并列在同一层的存在, 在贪心解法下,发现,被嵌套了偶数层的圆圈永远是要被减去的,而奇数层的圆圈是要加上的 ...

  9. CodeForces - 849B 几何

    题意:给n个点,问是否能两条平行线覆盖所有的点 思路:因为要求全部覆盖,所以我们第一个点肯定是会入其中一条直线,其实只用判前三个点的所有情况即可 #include<stdio.h> #in ...

随机推荐

  1. java 自动拆箱

    Integer a0 = ; Integer a1 = ; Integer b0 = ; Integer b1 = ; ; System.out.println(a0 == a1); >> ...

  2. 机器学习算法GBDT

    http://www-personal.umich.edu/~jizhu/jizhu/wuke/Friedman-AoS01.pdf https://www.cnblogs.com/bentuwuyi ...

  3. SQL大数据查询优化

    常写的SQL可能主要以实现查询出结果为主,但如果数据量一大,就会突出SQL查询语句优化的性能独特之处.一般的数据库设计都会建索引查询,这样较全盘扫描查询的确快了不少.下面总结下SQL查询语句的几个优化 ...

  4. JS对象格式化方法:pretty_format

    /* * 格式化 * */ var pretty_format = function (obj, indent) { if (obj === null) return 'null'; if (obj ...

  5. vue-cli配置

    转载--https://www.cnblogs.com/caideyipi/p/8187656.html 手撕vue-cli配置文件——config篇   最近一直在研究webpack,突然想看看vu ...

  6. 加域电脑登陆系统后桌面文件丢失,登录系统提示用户名为“Temp”。

    注册表中定位到“HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\ProfileList”, ...

  7. pyinstaller

    下载pyinstaller pip install pyinstaller 打包文件 pyinstaller -F run.py # 打包成单个文件

  8. day 06

    深浅拷贝 # 值拷贝:应用场景最多ls = [1, 'abc', [10]]​ls1 = ls  # ls1直接将ls中存放的地址拿过来# ls内部的值发生任何变化,ls1都会随之变化​ls2 = l ...

  9. C# 无法将类型为“__DynamicallyInvokableAttribute”的对象强制转换为类型...

    错误代码: //遍历方法特性 foreach (MethodInfo m in type.GetMethods()) { foreach(Attribute a in m.GetCustomAttri ...

  10. MemoryStream生成Excel

    public static MemoryStream ToExcel<T>(List<T> list, string filePath = null) { var memory ...