An overnight dance in discotheque CodeForces - 814D (几何)
大意: 给定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 (几何)的更多相关文章
- 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)\)个圆,圆与圆之间 ...
- An overnight dance in discotheque
An overnight dance in discotheque time limit per test 2 seconds memory limit per test 256 megabytes ...
- 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 ...
- codeforces 814D An overnight dance in discotheque
题目链接 正解:贪心. 首先我们可以计算出每个圆被多少个圆覆盖. 很显然,最外面的圆是肯定要加上的. 然后第二层的圆也是要加上的.那么第三层就不可能被加上了.同理,第四层的圆又一定会被加上. 然后我们 ...
- codeforces 814 D. An overnight dance in discotheque (贪心+bfs)
题目链接:http://codeforces.com/contest/814/problem/D 题意:给出奇数个舞者,每个舞者都有中心坐标和行动半径,而且这些点组成的园要么相互包含要么没有交集求,讲 ...
- CF#418 Div2 D. An overnight dance in discotheque
一道树形dp裸体,自惭形秽没有想到 首先由于两两圆不能相交(可以相切)就决定了一个圆和外面一个圆的包含关系 又可以发现这样的树中,奇数深度的圆+S,偶数深度的圆-S 就可以用树形dp 我又写挫了= = ...
- [CodeForces]CodeForces 13D 几何 思维
大致题意: 给出N个红点和M个蓝点,问可以有多少个红点构成的三角形,其内部不含有蓝点 假设我们现在枚举了一条线段(p[i],p[j]),我们可以记录线段下方满足(min(p[i].x,p[j].x)& ...
- Codeforces 814D
题意略. 思路: 由于不重合这个性质,我们可以将每一个堆叠的圆圈单独拿出来考虑,而不用去考虑其他并列在同一层的存在, 在贪心解法下,发现,被嵌套了偶数层的圆圈永远是要被减去的,而奇数层的圆圈是要加上的 ...
- CodeForces - 849B 几何
题意:给n个点,问是否能两条平行线覆盖所有的点 思路:因为要求全部覆盖,所以我们第一个点肯定是会入其中一条直线,其实只用判前三个点的所有情况即可 #include<stdio.h> #in ...
随机推荐
- vim中自动格式化代码
1,gg 跳转到第一行 2,shift+v 转到可视模式 3,shift+g 全选 4,按下神奇的 =
- ubuntu16.04SSH无法连接
提示错误:server responded "algorithm negotiation failed” 解决办法: 修改ssh的配置文件 /etc/ssh/sshd_config文件 在末 ...
- 解决ping不通win7主机
之前在路由器上ping笔记本发现ping不通,但是笔记本ping路由器通,也没多想.今天想起来可能是win7的防火墙作怪,以前上课虚拟机好像也是ping不通宿主机,但是宿主机能ping通虚拟机. 简单 ...
- linux之添加切换用户、系统变量、selinux、防火墙、系统中文乱码的讲解
######linux用户分类1.root 用户 linux皇帝 2.普通用户 贫民百姓 [root@oldboyedu-01 oldboy]# useradd oldboy[root@oldboye ...
- day09内存管理
复习 ''' 文件处理 1.操作文件的三步骤 -- 打开文件:硬盘的空间被操作系统持有 | 文件对象被应用程序持续 -- 操作文件:读写操作 -- 释放文件:释放操作系统对硬盘空间的持有 2.基础的读 ...
- ConcurrentHashMap源码理解
1.ConcurrentHashMap继承关系 ConcurrentHashMap继承了AbstractMap类,同时实现了ConcurrentMap接口. 2.ConcurrentHashMap构造 ...
- freeswitch 事件命令
1.uuid_bridge 桥接两条呼叫的腿. Usage: uuid_bridge <uuid> <other_uuid> uuid_bridge至少需要有一条腿是被呼通的. ...
- Host 'xxx' is not allowed to connect to this MySQL server.
mysql开启远程连接 今天在服务器安装了mysql,准备用mysqlguitools远程登录的时候出错,提示:Host 'xxx' is not allowed to connect to this ...
- 工作流Activiti入门教程
https://blog.csdn.net/chenweifu365/article/details/79032758/
- jQuery Validate和Thymeleaf相关
jQuery Validate https://www.cnblogs.com/liuhongfeng/p/5135676.html https://www.cnblogs.com/linjiqin/ ...