SHARE
TWEET

Untitled

a guest Apr 26th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. main(){
  5.     int n,a[100][100],i,j,k,mx=0;
  6.     cin>>n;
  7.     for(i=0;i<n;++i)
  8.         for(j=0;j<n;++j){
  9.             cin>>a[i][j];
  10.             if(a[i][j]<0)a[i][j]=1000000000;
  11.         }
  12.     for(k=0;k<n;++k)
  13.         for(i=0;i<n;++i)
  14.             for(j=0;j<n;++j)
  15.                 if(a[i][j]>a[i][k]+a[k][j]){
  16.                     a[i][j]=a[i][k]+a[k][j];
  17.                 }
  18.     k=0;
  19.     for(i=0;i<n;++i)
  20.         for(j=0;j<n;++j)
  21.             if(a[i][j]<1000000000&&a[i][j]>k)
  22.                 k=a[i][j];
  23.     cout<<k;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top