Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author : unlucky_13
- Problem_link :
- Category : EASY
- 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
- */
- #include<cstdio>
- #include<sstream>
- #include<cstdlib>
- #include<cctype>
- #include<cmath>
- #include<algorithm>
- #include<set>
- #include<queue>
- #include<stack>
- #include<list>
- #include<iostream>
- #include<fstream>
- #include<numeric>
- #include<string>
- #include<vector>
- #include<cstring>
- #include<map>
- #include<iterator>
- #define LL long long int
- const long long int inf = 20000000 ;
- const int maxn=300;
- using namespace std;
- struct point{
- int x,y ;
- };
- double DIS(point p1,point p2){
- double X = p1.x-p2.x ;
- double Y = p1.y-p2.y ;
- return sqrt(X*X+Y*Y) ;
- }
- int n ;
- point p[maxn] ;
- double dis[maxn][maxn];
- void FW(){
- for(int k=0;k<n;k++){
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- double MIN = max(dis[i][k],dis[k][j]) ;
- dis[i][j] = min(dis[i][j],MIN) ;
- /*if(dis[i][j]>MIN){
- dis[i][j]= MIN ;
- }*/
- }
- }
- }
- }
- int main() {
- freopen("C:\\Users\\Mazhar\\Desktop\\in.txt", "r", stdin);
- int ct=0 ;
- //scanf("%d",&n) ;
- while(1){
- scanf("%d",&n) ;
- if(!n) break ;
- //if(ct) printf("\n") ;
- for(int i=0;i<n;i++){
- scanf("%d %d",&p[i].x,&p[i].y) ;
- }
- for(int i=0;i<n;i++){
- dis[i][i] = inf ;
- for(int j=i+1;j<n;j++){
- dis[i][j] = dis[j][i] = DIS(p[i],p[j]) ;
- }
- }
- //d[0][0] = 0 ;
- FW() ;
- //double res=inf ;
- double res=dis[0][1] ;
- /*for(int i=0;i<n;i++){
- res = min(res,dis[i][1]) ;
- }*/
- printf("Scenario #%d\nFrog Distance = %0.3lf\n\n",++ct,res) ;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment