zoukankan      html  css  js  c++  java
  • CodeForces 333E. Summer Earnings

    time limit per test
    9 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gerald was quite an unusual schoolboy, he found quite unusual work. A certain Company agreed to pay him a certain sum of money if he draws them three identical circles on a plane. The circles must not interfere with each other (but they may touch each other). He can choose the centers of the circles only from the n options granted by the Company. He is free to choose the radius of the circles himself (all three radiuses must be equal), but please note that the larger the radius is, the more he gets paid.

    Help Gerald earn as much as possible.

    Input

    The first line contains a single integer n — the number of centers (3 ≤ n ≤ 3000). The following n lines each contain two integers xi, yi( - 104 ≤ xi, yi ≤ 104) — the coordinates of potential circle centers, provided by the Company.

    All given points are distinct.

    Output

    Print a single real number — maximum possible radius of circles. The answer will be accepted if its relative or absolute error doesn't exceed 10 - 6.

    Examples
    input
    3
    0 1
    1 0
    1 1
    output
    0.50000000000000000000
    input
    7
    2 -3
    -2 -3
    3 0
    -3 -1
    1 -2
    2 -2
    -1 0
    output
    1.58113883008418980000

    位运算

    在点与点之间两两连边,边按边权从大到小排序。

    从大到小依次加边,当图中首次出现三元环时,可以画出满足要求的圆,此时加入的这条边/2就是最大半径。

    是否出现环可以用bitset位运算判断。

     1 /*by SilverN*/
     2 #include<iostream>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<cstdio>
     6 #include<cmath>
     7 #include<bitset>
     8 using namespace std;
     9 const int mxn=3030;
    10 int read(){
    11     int x=0,f=1;char ch=getchar();
    12     while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    13     while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
    14     return x*f;
    15 }
    16 struct pt{int x,y;}a[mxn];
    17 struct edge{int x,y;double w;
    18 }e[mxn*mxn/2];
    19 int cmp(const edge a,const edge b){return a.w>b.w;}
    20 int ect=0;
    21 bitset<3030>b[3030];
    22 int n;
    23 int main(){
    24     int i,j;
    25     n=read();
    26     for(i=1;i<=n;i++){
    27         a[i].x=read();a[i].y=read();
    28     }
    29     for(i=1;i<n;i++)
    30         for(j=i+1;j<=n;j++){
    31             e[++ect]=(edge){i,j,sqrt((double)(a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y))};
    32         }
    33     sort(e+1,e+ect+1,cmp);
    34     for(i=1;i<=ect;i++){
    35         int u=e[i].x,v=e[i].y;
    36         if((b[u]&b[v]).any()){
    37             printf("%.8f
    ",e[i].w/2);return 0;
    38         }
    39         b[u][v]=1;b[v][u]=1;
    40     }
    41     return 0;
    42 }
  • 相关阅读:
    你的内存不够啦:c++: internal compiler error: Killed (program cc1plus)
    ARM交叉编译器GNUEABI、NONE-EABI、ARM-EABI、GNUEABIHF等的区别
    arm-linux-gnueabihf、aarch64-linux-gnu等ARM交叉编译GCC的区别
    ubuntu与centos的对比和选择
    Deep Convolutional Network Cascade for Facial Point Detection实践总结
    深度学习(十七)基于改进Coarse-to-fine CNN网络的人脸特征点定位
    《Deep Convolutional Network Cascade for Facial Point Detection》复现
    使用axis2,根据WSDL生成java客户端代码
    oracle字段NCHAR查询,
    【转】fastdfs第一次上传文档报错recv package size
  • 原文地址:https://www.cnblogs.com/SilverNebula/p/6329616.html
Copyright © 2011-2022 走看看