zoukankan      html  css  js  c++  java
  • codeforces Summer Earnings(bieset)

    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.

    Sample test(s)
    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





     1 //代码心得:用cmp  5178 ms:用运算符重载  1590 ms!!!!
     2 //编程心得:当 边从大到小排完序后  要判断这条边是否
     3 //与之前的边可以构成三角形;可以用bitset  (v[i] & v[j]).any()  
     4 //如果true  说明 存在k  与 i,j都有边   且ki与kj都大于ij!!! 
     5 
     6 
     7 #include<stdio.h>
     8 #include<string.h>
     9 #include<math.h>
    10 #include<set>
    11 #include<vector>
    12 #include<map>
    13 #include<queue>
    14 #include <cstring>
    15 #include <algorithm>
    16 #include <cmath>
    17 #include <bitset>
    18 using namespace std;
    19 
    20 const int N = 3010;
    21 
    22 struct node {
    23     int d;
    24     int i, j;
    25        bool operator<(node a) const
    26     {
    27         return d>a.d;//从大到小!!!! 
    28     }
    29 }a[N * N];
    30 
    31 int x[N], y[N];
    32 bitset<N> v[N];
    33 
    34 int main() {
    35     int n;
    36     scanf("%d", &n);
    37     for (int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
    38     int na = 0;
    39     for (int i = 0; i < n; i++)
    40         for (int j = i + 1; j < n; j++) {
    41             a[na].i = i; a[na].j = j;
    42             int dx = x[i] - x[j];
    43             int dy = y[i] - y[j];
    44             a[na].d = dx * dx + dy * dy;
    45             na++;
    46         }
    47     sort(a, a + na);
    48     int ans;
    49     //for(int i=0;i<na;i++) printf("%.4f**
    ", sqrt(a[i].d));
    50     for (int k = 0; k < na; k++) {
    51         int i = a[k].i, j =  a[k].j;
    52         if ((v[i] & v[j]).any()) {
    53             ans = a[k].d;
    54             break;
    55         }
    56         v[i][j] = v[j][i] = 1;
    57     }
    58     printf("%.10f
    ", sqrt(ans) * 0.5);
    59     return 0;
    60 }
    View Code
  • 相关阅读:
    Python数据分析的几种绘图方式——数据可视化(附源码)
    Python GUI项目实战:主窗体的界面设计与实现
    Python Scrapy框架:数据爬取全流程
    python来爬取煎蛋网随手拍小姐姐图片
    有意思的逻辑小练习:函数做参数进行传递
    python值*args和**kwargs的总结思考
    数据类型的基础知识补充,字典的并交集、空集合、可作为字典元组的元素、删除字典中的元素
    python里面为什么shell和保存文件运行结果不一样的相关思考(内存相关)
    代码:购物车(待修改)
    python里面为什么shell和保存文件运行结果不一样?
  • 原文地址:https://www.cnblogs.com/skykill/p/3236355.html
Copyright © 2011-2022 走看看