• 洛谷1522


    挺有意思的hhh有个坑

     1 #include<cstdio> 
     2 #include<cstring>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<set>
     9 #define inf (1e10)
    10 #define l(a) ((a)<<1)
    11 #define r(a) ((a)<<1|1)
    12 #define b(a) (1<<(a))
    13 #define rep(i,a,b) for(int i=a;i<=(b);i++)
    14 #define clr(a) memset(a,0,sizeof(a))
    15 typedef long long ll;
    16 typedef unsigned long long ull;
    17 using namespace std;
    18 int readint(){
    19     int t=0,f=1;char c=getchar();
    20     while(!isdigit(c)){
    21         if(c=='-') f=-1;
    22         c=getchar();
    23     }
    24     while(isdigit(c)){
    25         t=(t<<3)+(t<<1)+c-'0';
    26         c=getchar();
    27     }
    28     return t*f;
    29 }
    30 const int maxn=209;
    31 int n,x[maxn],y[maxn];
    32 double d[maxn][maxn],w[maxn];
    33 double dis(int a,int b){
    34     return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
    35 }
    36 int main(){
    37     //freopen("#input.txt","r",stdin);
    38     //freopen("#output.txt","w",stdout);
    39     n=readint();
    40     rep(i,1,n){
    41         x[i]=readint();y[i]=readint(); 
    42     }
    43     rep(i,1,n)
    44         rep(j,1,n){
    45             char c=getchar();
    46             while(c!='0'&&c!='1') c=getchar();
    47             if(c=='0'&&i!=j) d[i][j]=inf;
    48             else d[i][j]=dis(i,j);
    49         }
    50     rep(k,1,n)
    51         rep(i,1,n)
    52             rep(j,1,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    53     rep(i,1,n)
    54         rep(j,1,n) if(d[i][j]!=inf) w[i]=max(w[i],d[i][j]);
    55     double ans=inf;
    56     rep(i,1,n)
    57         rep(j,1,n) if(d[i][j]==inf) ans=min(ans,w[i]+w[j]+dis(i,j));
    58     rep(i,1,n) ans=max(ans,w[i]);
    59     printf("%.6lf
    ",ans);
    60     //fclose(stdin);
    61     //fclose(stdout);
    62     return 0;
    63 }
    View Code
  • 相关阅读:
    Linux常用操作命令总结
    Centos7安装FastDFS教程
    Permutation Sequence
    Next Permutation
    Remove Element
    4Sum
    3Sum Closest
    3Sum
    Longest Consecutive Sequence
    Median of Two Sorted Arrays
  • 原文地址:https://www.cnblogs.com/chensiang/p/8045295.html
Copyright © 2020-2023  润新知