题意

PDF

分析

两两圆求交点,对每个圆弧按半径抖动。

时间复杂度\(O(T n^2)\)

代码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<ctime>
#include<cstring>
#define rg register
#define il inline
#define co const
template<class T>il T read()
{
    rg T data=0;
    rg int w=1;
    rg char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-')
            w=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        data=data*10+ch-'0';
        ch=getchar();
    }
    return data*w;
}
template<class T>T read(T&x)
{
    return x=read<T>();
}
using namespace std;
typedef long long ll;

co double eps=5e-13;

int dcmp(double x)
{
    if(fabs(x)<0)
        return 0;
    else
        return x<0?-1:1;
}

co double PI=acos(-1);

double NormalizeAngle(double rad,double center=PI)
{
    return rad-PI*2*floor((rad+PI-center)/(PI*2));
}

struct Point
{
    double x,y;

    Point(double x=0,double y=0)
    :x(x),y(y){}

    double angle()
    {
        return atan2(y,x);
    }
};
typedef Point Vector;

Vector operator+(Vector A,Vector B)
{
    return Vector(A.x+B.x,A.y+B.y);
}

Vector operator-(Point A,Point B)
{
    return Vector(A.x-B.x,A.y-B.y);
}

Vector operator*(Vector A,double p)
{
    return Vector(A.x*p,A.y*p);
}

Vector operator/(Vector A,double p)
{
    return Vector(A.x/p,A.y/p);
}

double Dot(Vector A,Vector B)
{
    return A.x*B.x+A.y*B.y;
}

double Length(Vector A)
{
    return sqrt(Dot(A,A));
}

void CircleCircleIntersection(Point c1,double r1,Point c2,double r2,vector<double>&rad)
{
    double d=Length(c1-c2);
    if(dcmp(d)==0)
        return;
    if(dcmp(r1+r2-d)<0)
        return;
    if(dcmp(fabs(r1-r2)-d)>0)
        return;

    double a=(c2-c1).angle();
    double da=acos((r1*r1+d*d-r2*r2)/(2*r1*d));
    rad.push_back(NormalizeAngle(a-da));
    rad.push_back(NormalizeAngle(a+da));
}

co int N=100;
int n;
Point center[N];
double radius[N];
bool vis[N];

int topmost(Point p)
{
    for(int i=n-1;i>=0;--i)
        if(dcmp(Length(center[i]-p)-radius[i])<0)
            return i;
    return -1;
}

int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    while(read(n))
    {
        for(int i=0;i<n;++i)
            scanf("%lf %lf %lf",&center[i].x,&center[i].y,&radius[i]);
        fill(vis,vis+n,0);
        for(int i=0;i<n;++i)
        {
            vector<double>rad;
            rad.push_back(0);
            rad.push_back(PI*2);
            for(int j=0;j<n;++j)
                CircleCircleIntersection(center[i],radius[i],center[j],radius[j],rad);
            sort(rad.begin(),rad.end());

            for(int j=0;j<rad.size();++j)
            {
                double mid=(rad[j]+rad[j+1])/2;
                for(int side=-1;side<=1;side+=2)
                {
                    double r2=radius[i]-side*eps;
                    int t=topmost(Point(center[i].x+cos(mid)*r2,center[i].y+sin(mid)*r2));
                    if(t>=0)
                        vis[t]=1;
                }
            }
        }
        int ans=0;
        for(int i=0;i<n;++i)
            if(vis[i])
                ++ans;
        printf("%d\n",ans);
    }
    return 0;
}

LA2572 Viva Confetti的更多相关文章

  1. poj1418 Viva Confetti 判断圆是否可见

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Viva Confetti Time Limit: 1000MS   Memory ...

  2. poj 1418 Viva Confetti

    Viva Confetti Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1025   Accepted: 422 Desc ...

  3. ZOJ 1696 Viva Confetti 计算几何

    计算几何:按顺序给n个圆覆盖.问最后能够有几个圆被看见.. . 对每一个圆求和其它圆的交点,每两个交点之间就是可能被看到的圆弧,取圆弧的中点,往外扩展一点或者往里缩一点,从上往下推断有没有圆能够盖住这 ...

  4. uva 2572 Viva Confetti

    思路: 小圆面是由小圆弧围成.那么找出每条小圆弧,如果小圆弧,在小圆弧中点上下左右进行微小位移的所得的点一定在一个小圆面内. 找到最后覆盖这个小点的圆一定是可见的. 圆上的点按照相邻依次排序的关键量为 ...

  5. uva 1308 - Viva Confetti

    这个题目的方法是将圆盘分成一个个圆环,然后判断这些圆环是否被上面的圆覆盖: 如果这个圆的圆周上的圆弧都被上面的覆盖,暂时把它标记为不可见: 然后如果他的头上有个圆,他有个圆弧可见,那么他自己本身可见, ...

  6. UVaLive2572 poj1418 UVa1308 Viva Confetti

    一次放下n个圆 问最终可见的圆的数量 应该是比较经典的问题吧 考虑一个圆与其他每个圆的交点O(n)个 将其割成了O(n)条弧 那么看每条弧的中点 分别向内向外调动eps这个点 则最上面的覆盖这个点的圆 ...

  7. [GodLove]Wine93 Tarining Round #9

    比赛链接: http://vjudge.net/contest/view.action?cid=48069#overview 题目来源: lrj训练指南---二维几何计算   ID Title Pro ...

  8. POJ 1418 基本操作和圆 离散弧

    Viva Confetti Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 761   Accepted: 319 Descr ...

  9. Thesis Viva checklist

    This list gives you suggestions helpful in preparing to defend your thesis: I know my thesis thoroug ...

随机推荐

  1. 插入算法分别从C,java,python三种语言进行书写

    真正学懂计算机的人(不只是“编程匠”)都对数学有相当的造诣,既能用科学家的严谨思维来求证,也能用工程师的务实手段来解决问题——而这种思维和手段的最佳演绎就是“算法”. 作为一个初级编程人员或者说是一个 ...

  2. 智能穿戴设备移动APP端与外设数据传输协议功能模块CMD&ACK表

    Notification Module Function CMD ACK Notification History Count [0x0301] [0x0000] [0x01] [0x0301] [0 ...

  3. Git如何进行分支管理?

    Git如何进行分支管理?     1.创建分支     创建分支很简单:git branch <分支名>     2.切换分支     git checkout <分支名>   ...

  4. UOJ34 多项式乘法(非递归版)

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  5. Codeforces Round #365 (Div. 2) D.Mishka and Interesting sum 树状数组+离线

    D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes in ...

  6. Ceph 纠删码介绍

    http://ceph.org.cn/2016/08/01/ceph-%E7%BA%A0%E5%88%A0%E7%A0%81%E4%BB%8B%E7%BB%8D/

  7. 用Heartbeat实现HA集群

    HA即高可用(high avaliable),又被叫做双机热备,用于关键性业务,简单理解就是,有两台机器A和B,正常是A提供服务,B待机闲置,当A宕机或服务宕掉,会切换到B机器继续提供服务.常用实现高 ...

  8. hdu1695莫比乌斯反演模板题

    hdu1695 求1<=i<=n&&1<=j<=m,gcd(i,j)=k的(i,j)的对数 最后的结果f(k)=Σ(1<=x<=n/k)mu[x]* ...

  9. 用verilog来描述组合逻辑电路

    1,什么是组合逻辑电路? 逻辑电路在任何时刻产生的稳定的输出信号仅仅取决于该时刻的输入信号,而与过去的输入信号无关,即与输入信号作用前的状态无关,这样的电路称为组合逻辑电路. 上图给出了一个典型的数字 ...

  10. Database项目中关于Procedure sp_refreshsqlmodule_internal的错误

    最近项目中发现一怪问题,使用DB项目发布数据库时,总提示 “(110,1): SQL72014: .Net SqlClient Data Provider: Msg 1222, Level 16, S ...