unlucky_13

uva_534

Jun 16th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. /*
  2.  Author                             :     unlucky_13
  3.  Problem_link                       :
  4.  Category                           : EASY
  5.  Algorithm_Used                     : Floyed Marshall APSP read the problem statemaent carefully there is black line after each test case answer got WA 1st time only for this
  6.  
  7.  */
  8.  
  9. #include<cstdio>
  10. #include<sstream>
  11. #include<cstdlib>
  12. #include<cctype>
  13. #include<cmath>
  14. #include<algorithm>
  15. #include<set>
  16. #include<queue>
  17. #include<stack>
  18. #include<list>
  19. #include<iostream>
  20. #include<fstream>
  21. #include<numeric>
  22. #include<string>
  23. #include<vector>
  24. #include<cstring>
  25. #include<map>
  26. #include<iterator>
  27. #define LL long long int
  28. const long long int inf = 20000000 ;
  29. const int maxn=300;
  30.  
  31. using namespace std;
  32. struct point{
  33.     int x,y ;
  34. };
  35.  
  36. double DIS(point p1,point p2){
  37.     double X = p1.x-p2.x ;
  38.     double Y = p1.y-p2.y ;
  39.     return sqrt(X*X+Y*Y) ;
  40. }
  41. int n ;
  42. point p[maxn] ;
  43. double dis[maxn][maxn];
  44. void FW(){
  45.  
  46.     for(int k=0;k<n;k++){
  47.         for(int i=0;i<n;i++){
  48.             for(int j=0;j<n;j++){
  49.                 double MIN = max(dis[i][k],dis[k][j]) ;
  50.                 dis[i][j] = min(dis[i][j],MIN) ;
  51.                 /*if(dis[i][j]>MIN){
  52.                     dis[i][j]= MIN ;
  53.                 }*/
  54.             }
  55.         }
  56.     }
  57.  
  58. }
  59.  
  60.  
  61.  
  62. int main() {
  63.  
  64.     freopen("C:\\Users\\Mazhar\\Desktop\\in.txt", "r", stdin);
  65.     int ct=0 ;
  66.     //scanf("%d",&n) ;
  67.     while(1){
  68.         scanf("%d",&n) ;
  69.         if(!n) break ;
  70.         //if(ct) printf("\n") ;
  71.         for(int i=0;i<n;i++){
  72.             scanf("%d %d",&p[i].x,&p[i].y) ;
  73.         }
  74.  
  75.         for(int i=0;i<n;i++){
  76.             dis[i][i] = inf ;
  77.             for(int j=i+1;j<n;j++){
  78.                 dis[i][j] = dis[j][i] =  DIS(p[i],p[j]) ;
  79.             }
  80.         }
  81.         //d[0][0] = 0 ;
  82.         FW() ;
  83.         //double res=inf ;
  84.         double res=dis[0][1] ;
  85.         /*for(int i=0;i<n;i++){
  86.             res = min(res,dis[i][1]) ;
  87.         }*/
  88.         printf("Scenario #%d\nFrog Distance = %0.3lf\n\n",++ct,res) ;
  89.  
  90.     }
  91.  
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment