计算几何真的好暴力啊。

#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define max(a,b) (a) > (b) ? (a) : (b)
#define N 1003
using namespace std;
const double Pi = acos(-1);
inline int dcmp(double x) {return (fabs(x) < 1e-6) ? 0 : (x < 0 ? -1 : 1);}
inline double sqr(double x) {return x * x;}
struct Point {
double x, y;
Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
};
struct Rround {
Point O; double R;
Rround(Point _O = Point(0, 0), double _R = 0) : O(_O), R(_R) {}
};
Point operator - (Point a, Point b) {return Point(a.x - b.x, a.y - b.y);}
inline double dis(Rround a, Rround b) {return sqrt(sqr(a.O.x - b.O.x) + sqr(a.O.y - b.O.y));}
inline bool cover(Rround to, Rround now) {return to.R >= now.R + dis(to, now);}
struct Splay {
double l, r;
Splay(double _l = 0, double _r = 0) : l(_l), r(_r) {}
}; Splay s[N];
int n, top;
double ans = 0, tt, nxt;
Rround r[N];
bool pd; inline void ins(Rround a, Rround b) {
double d = dis(a, b), t, st, l;
t = (sqr(a.R) - sqr(b.R) + sqr(d)) / (d + d);
st = atan2((a.O.y - b.O.y), (a.O.x - b.O.x));
//st = atan2((a.O.x - b.O.x), (a.O.y - b.O.y));
l = acos(t / a.R);
s[++top] = Splay(st - l, st + l);
}
inline bool cmp(Splay a, Splay b) {return a.l < b.l;} int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%lf%lf%lf", &r[i].R, &r[i].O.x, &r[i].O.y); for(int i = 1; i <= n; ++i) {
pd = 0;
for(int j = i + 1; j <= n; ++j)
if (cover(r[j], r[i])) {
pd = 1;
break;
}
if (pd)
continue; top = 0;
for(int j = i + 1; j <= n; ++j)
if (!cover(r[i], r[j]) && r[i].R + r[j].R >= dis(r[i], r[j]))
ins(r[i], r[j]); for(int j = 1; j <= top; ++j) {
if (s[j].l < 0) s[j].l += 2 * Pi;
if (s[j].r < 0) s[j].r += 2 * Pi;
if (s[j].l > s[j].r) {
s[++top] = Splay(0, s[j].r);
s[j].r = 2 * Pi;
}
} sort(s + 1, s + top + 1, cmp); tt = 0; nxt = 0;
for(int j = 1; j <= top; ++j)
if (s[j].l > nxt) {
tt += s[j].l - nxt;
nxt = s[j].r;
} else
nxt = max(nxt, s[j].r);
tt += 2 * Pi - nxt; ans += tt * r[i].R;
} printf("%.3lf\n",ans);
return 0;
}

可惜一开始$π$设为$int$了查了$2h$的错QAQ横坐标相减打错查了$1h+$TWT

【BZOJ 1043】【HNOI 2008】下落的圆盘 判断圆相交+线段覆盖的更多相关文章

  1. [bzoj 1004][HNOI 2008]Cards(Burnside引理+DP)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1004 分析: 1.确定方向:肯定是组合数学问题,不是Polya就是Burnside,然后题目上 ...

  2. BZOJ 1009 HNOI 2008 GT考试 递推+矩乘

    1009: [HNOI2008]GT考试 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3679  Solved: 2254[Submit][Statu ...

  3. [bzoj 1005][HNOI 2008]明明的烦恼(prufer数列+排列组合)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1005 分析: 首先prufer数列:http://baike.baidu.com/view/1 ...

  4. BZOJ 1007 HNOI 2008 水平可见直线 计算几何+栈

    题目大意:给出一些笛卡尔系中的一些直线,问从(0,+∞)向下看时能看到哪些直线. 思路:半平面交可做,可是显然用不上. 类似于求凸包的思想,维护一个栈. 先将全部直线依照k值排序.然后挨个压进去,遇到 ...

  5. [bzoj 1010][HNOI 2008]玩具装箱

    传送门 Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压 缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号 ...

  6. [bzoj] 1043 下落的圆盘 || 圆上的“线段覆盖”

    原题 n个圆盘,求下落后能看到的总周长. 红色即为所求 借鉴于黄学长的博客 对于每下落的一个圆盘,处理他后面的圆盘会挡住哪些区域,然后把一整个圆(2\(/pi\))当做一整个区间,每个被覆盖的部分都可 ...

  7. bzoj 1043 下落的圆盘 —— 求圆心角、圆周长

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1043 求出每个圆没被覆盖的长度即可: 特判包含和相离的情况,注意判包含时 i 包含 j 和 ...

  8. 1043: [HAOI2008]下落的圆盘

    Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1725  Solved: 743[Submit][Status][Discuss] Descripti ...

  9. BZOJ1043:[HAOI2008]下落的圆盘——题解(配图片)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1043 Description 有n个圆盘从天而降,后面落下的可以盖住前面的.求最后形成的封闭区域的周 ...

随机推荐

  1. OpenCV 之 边缘检测

    上一篇 <OpenCV 之 图像平滑> 中,提到的图像平滑,从信号处理的角度来看,实际上是一种“低通滤波器”. 本篇中,数字图像的边缘,因为通常都是像素值变化剧烈的区域 (“高频”),故可 ...

  2. 《Writing Idiomatic Python》前两部分的中文翻译

    汇总了一下这本小书前两部分的内容: 翻译<Writing Idiomatic Python>(一):if语句.for循环 翻译<Writing Idiomatic Python> ...

  3. SoapUI调用webservice实现的两种方式

    SoapUI用来做测试,已经是很多人做过的事情了,而且网上教程也很多.不过还是写下来,对比webservice协议与http协议脚本编写的不同. 首先测接口得有一个服务,刚好笔者所在项目做ESB集成. ...

  4. WinCE项目应用之RM905a+医用放射性核素活度计

    RM905a+医用放射性核素活度计大概是我做的第一个WinCE项目,RM905a的升级版.RM905a是曾经的老大LZF 2000年左右的作品,基于51单片机开发,数码管显示,稳定可靠,好似目前还在生 ...

  5. http协议(一)基础知识

    我自己写的随笔一般是偏学习笔记性质的,或者一点个人理解,适合新人,大牛可以忽略这个...... 参考书籍——<图解http> 当我们在浏览器的地址栏中输入网址,然后点击回车,接着,浏览器就 ...

  6. Mysql连接错误:Lost connection to Mysql server at 'waiting for initial communication packet'

    在远程连接mysql的时候,连接不上,出现如下报错:Lost connection to MySQL server at 'waiting for initial communication pack ...

  7. shenben语录

    1.别让别人的一句话将你击垮! 2.任何人都不能替你做决定,除了你自己! 3.对于省选: 想去就去,文化课什么的都不是问题. 如果不去,二十年后的自己一定会后悔的.

  8. Openjudge 3.9-3339

    3339:List 总时间限制: 4000ms 内存限制: 65536kB 描述 写一个程序完成以下命令:new id --新建一个指定编号为id的序列(id<10000)add id num- ...

  9. There is no ‘Animation’ attached to the “Player” game object

    There is no ‘Animation’ attached to the “Player” game object 在照着龚老师的Unity3D投篮游戏视频教程练习时,遇到这个错误提示. 我知道 ...

  10. ios更新UI时请尝试使用performSelectorOnMainThread方法

    最近开发项目时发现联网获取到数据后,使用通知方式让列表刷新会存在死机的问题. 经过上网查找很多文章,都建议使用异步更新的方式,可是依然崩溃. 最后尝试使用performSelectorOnMainTh ...