码迷,mamicode.com
首页 > 其他好文 > 详细

洛谷1522

时间:2017-12-16 00:38:24      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:pac   cstring   ctime   body   max   分享   post   none   getchar   

挺有意思的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\n",ans);
60     //fclose(stdin);
61     //fclose(stdout);
62     return 0;
63 }
View Code

 

洛谷1522

标签:pac   cstring   ctime   body   max   分享   post   none   getchar   

原文地址:http://www.cnblogs.com/chensiang/p/8045295.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!