博客园的话插链接链接都是凉的= =

题解

我理解成能不能看到这个圆,除了最后几个圆特殊以外都是等价的,然而我凉了,因为我把圆当成线段来处理,但是,有可能一个圆完全被遮住了,还有一个缝隙,就WA了

计算几何题这点最不好,WA了会想的第一件事就是垃圾OJ卡我精度,反复WA上几次才会知道,自己算法错了

那么首先每个圆的位置取决于能被左边的圆最远推到哪里,这个就是以两圆圆心距和竖直两条半径(是个梯形)算出来就行,能被推说明圆心距必然是半径之和,不断取max并同时记录是哪个圆推的它

最后取最后一个碰到某个圆的圆,并删除他们之间所有点,特判一下第一个碰到最远距离的圆pos[i] + r[i]的最大值所在的i并删除之后的圆

为什么我叙述那么混乱可能我太久没上语文课吧(手动再见)

代码

#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstring>
#include <ctime>
#include <map>
#include <algorithm>
#include <cmath>
#define MAXN 1005
#define eps 1e-8
//#define ivorysi
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long int64;
typedef double db;
int N,tot,ans[MAXN],touch[MAXN];
db R[MAXN],pos[MAXN];
bool dcmp(db a,db b) {
return fabs(a - b) < eps;
}
struct Point {
db x,y;
Point(){}
Point(db _x,db _y) {
x = _x;y = _y;
}
friend Point operator + (const Point &a,const Point &b) {
return Point(a.x + b.x,a.y + b.y);
}
friend Point operator - (const Point &a,const Point &b) {
return Point(a.x - b.x,a.y - b.y);
}
friend Point operator * (const Point &a,db d) {
return Point(a.x * d,a.y * d);
}
friend Point operator / (const Point &a,db d) {
return Point(a.x / d,a.y / d);
}
friend db operator * (const Point &a,const Point &b) {
return a.x * b.y - a.y * b.x;
}
friend db dot(const Point &a,const Point &b) {
return a.x * b.x + a.y * b.y;
}
db norm() {
return sqrt(x * x + y * y);
}
}P[MAXN];
struct Seg {
Point a,b;
db d;
Seg(){}
Seg(Point _a,Point _b) {
a = _a;b = _b;d = atan2(b.y - a.y,b.x - a.x);
}
friend Point Cross_Point(const Seg &s,const Seg &t) {
db S1 = (s.a - t.a) * (t.b - t.a);
db S2 = (s.b - t.b) * (t.a - t.b);
return s.a + (s.b - s.a) * (S1 / (S1 + S2));
}
friend bool operator < (const Seg &s,const Seg &t) {
return s.d < t.d;
}
}S[MAXN];
inline db o(db x) {return x * x;}
void Solve() {
//scanf("%d",&N);
tot = 0;
for(int i = 1 ; i <= N ; ++i) scanf("%lf",&R[i]);
db L = 0.0;
for(int i = 1 ; i <= N ; ++i) {
pos[i] = R[i];
touch[i] = 0;
for(int j = 1 ; j < i ; ++j) {
db x = pos[j] + sqrt(R[i] * R[j]) * 2;
if(x > pos[i] + eps) {
pos[i] = x;
touch[i] = j;
}
}
L = max(L,pos[i] + R[i]);
}
int last = 0;
while(1) {
if(dcmp(pos[last] + R[last],L)) {
for(int i = last + 1 ; i <= N ; ++i) ans[++tot] = i;
break;
}
int v = 0;
for(int i = last + 1 ; i <= N ; ++i) {
if(touch[i] == last) v = i;
}
for(int i = last + 1 ; i < v ; ++i) ans[++tot] = i;
last = v;
} printf("%d\n",tot);
for(int i = 1 ; i <= tot ; ++i) {
printf("%d\n",ans[i]);
}
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
while(scanf("%d",&N) != EOF && N) {
Solve();
}
return 0;
}

【POJ】1819.Disks的更多相关文章

  1. 【POJ】1704 Georgia and Bob(Staircase Nim)

    Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, ...

  2. 【POJ】1067 取石子游戏(博弈论)

    Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后 ...

  3. 【BZOJ】【1986】【USACO 2004 Dec】/【POJ】【2373】划区灌溉

    DP/单调队列优化 首先不考虑奶牛的喜欢区间,dp方程当然是比较显然的:$ f[i]=min(f[k])+1,i-2*b \leq k \leq i-2*a $  当然这里的$i$和$k$都是偶数啦~ ...

  4. 【POJ】【2104】区间第K大

    可持久化线段树 可持久化线段树是一种神奇的数据结构,它跟我们原来常用的线段树不同,它每次更新是不更改原来数据的,而是新开节点,维护它的历史版本,实现“可持久化”.(当然视情况也会有需要修改的时候) 可 ...

  5. 【POJ】1222 EXTENDED LIGHTS OUT

    [算法]高斯消元 [题解] 高斯消元经典题型:异或方程组 poj 1222 高斯消元详解 异或相当于相加后mod2 异或方程组就是把加减消元全部改为异或. 异或性质:00 11为假,01 10为真.与 ...

  6. 【POJ】2892 Tunnel Warfare

    [算法]平衡树(treap) [题解]treap知识见数据结构 在POJ把语言从G++换成C++就过了……??? #include<cstdio> #include<algorith ...

  7. 【POJ】【1637】Sightseeing tour

    网络流/最大流 愚人节快乐XD 这题是给一个混合图(既有有向边又有无向边),让你判断是否有欧拉回路…… 我们知道如果一个[连通]图中每个节点都满足[入度=出度]那么就一定有欧拉回路…… 那么每条边都可 ...

  8. 【poj】1001

    [题目] ExponentiationTime Limit: 500MS Memory Limit: 10000KTotal Submissions: 123707 Accepted: 30202De ...

  9. 【POJ】3070 Fibonacci

    [算法]矩阵快速幂 [题解] 根据f[n]=f[n-1]+f[n-2],可以构造递推矩阵: $$\begin{vmatrix}1 & 1\\ 1 & 0\end{vmatrix} \t ...

随机推荐

  1. python中的文本操作

    python如何进行文本操作 1.能调用方法的一定是对象,比如数值.字符串.列表.元组.字典,甚至文件也是对象,Python中一切皆为对象. str1 = 'hello' str2 = 'world' ...

  2. [转]windows下安装python MySQLdb及问题解决

    转自 https://blog.csdn.net/ping523/article/details/54135228#commentBox 之前按照网络上搜罗的教程安装了python-mysql(1.2 ...

  3. Java并发编程原理与实战二十五:ThreadLocal线程局部变量的使用和原理

    1.什么是ThreadLocal ThreadLocal顾名思义是线程局部变量.这种变量和普通的变量不同,这种变量在每个线程中通过get和set方法访问, 每个线程有自己独立的变量副本.线程局部变量不 ...

  4. 【js学习笔记】去除省、市、区、特别行政区、自治区

    不是很懂js,以前去除这些省.市.区的时候都是用的分支判断indexOf,如果!=-1则replace一次,今天看同事的代码,发现还有更简单的办法... var areaName = str.repl ...

  5. protobuffer

    [protobuffer] 1.扩展名为.proto. 2.定义一个协议: 3.定义一个Service: 4.编译器为protoc,使用protoc: 5.style:所有的类型名均CamelCase ...

  6. windows git gui右键sublime打开当前文件编辑

    git安装目录\Git\libexec\git-core\git-gui.tcl的 proc create_common_diff_popup 下追加: $ctxm add command \ -la ...

  7. Spark1.3.1 On Yarn的集群搭建

    下面给出的是spark集群搭建的环境: 操作系统:最小安装的CentOS 7(下载地址) Yarn对应的hadoop版本号:Hadoop的Cloudera公司发行版Hadoop2.6.0-CDH5.4 ...

  8. sql 通过分数字段倒排获取名次的方法

    row_number() over(order by sort desc) 应用场景: 比如学员成绩表中有userid,username,sorce登字段,需要取出学员成绩的名次:表中没有名次字段,只 ...

  9. 【译】第十二篇 Integration Services:高级日志记录

    本篇文章是Integration Services系列的第十二篇,详细内容请参考原文. 简介在前一篇文章我们配置了SSIS内置日志记录,演示了简单和高级日志配置,保存并查看日志配置,生成自定义日志消息 ...

  10. JS事件用法

    1.常用事件理解