Oh yes , It works , My bad 
Ok , next time I will use this , thank you very much @spaanse
Hey I was trying this as well but could debug mine. If your works can you tell me where I am wrong. Thank you 
#include<bits/stdc++.h>
using namespace std;
int dp[110][110];
const int inf = 1e9;
int main(){
int n,m,a,b,d;
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
dp[i][j] = (i == j ? 0 : inf);
while(m--){
scanf("%d%d%d",&a,&b,&d);
dp[a][b] = min(dp[a][b],d);
}
for(int k = 1; k <= n; ++k){
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
if(dp[i][k] < inf && dp[k][j] < inf)
dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
}
}
}
for(int i = 1; i <= n; ++i)printf("%d ",dp[1][i]);
return 0;
}
I did not know that exists, indeed the syntax is cleaner. As it does exactly the same as typedef I won’t change my c++ init snippet.
if DP[i][j] == INF then print 30000
Not received mail for account verification from that site 

one more doubt let say we have undirected +ve weighted tree , Now we have to Find two vertices the distance between which is minimum , not need to print vertices just print distance , so what we can do is -
lli dp[n][n];
loop(i,n)
{
loop(j,n)
{
if(i==j)
dp[i][j]=0;
else
dp[i][j] = INF;
}
}
loop(i,m)
{
lli x,y,cost;
cin>>x>>y>>cost;
--x;
y--;
dp[x][y] = cost;
dp[y][x] = cost;
}
loop(k,n)
{
loop(i,n)
{
loop(j,n)
{
dp[i][j] = min(dp[i][j] , dp[i][k]+dp[k][j]);
}
}
}
lli ans = INF;
loop(i,n)
loop(j,n)
if(i!=j)
ans = min(ans , dp[i][j])
print(ans);
But what if we have to find the maximum distance , I did by taking -INF but not correct answer.
@ssjgz @spaanse
I believe the following will work, if the time limit accepts \mathcal{O}(n^3):
... floyd warschall
lli ans = 0;
loop(i,n)
loop(j,n)
ans = max(ans,dp[i][j]);
print(ans);
Otherwise use the algorithm for finding a graph diameter.
It find the minimum path right ?
But I want max path so can u please tell me the code for floyd warshall for MAX path
Yes , N3 is too much and not allowed too , but i just did floyd warshall for min path but don’t figure out for max path.
That is the thing, in a tree the minimum simple path between any two vertices is also the maximum simple path between those vertices. Because there are no cycles there is exactly one path between each pair of vertices.
Oh shit man , I always mistake in graph vs tree
, BTW what if it is graph then how the conditions will change please tell.
For the general graph using floyd warschall is one of the best algorithms.
For the longest minimum distance between any pair of nodes
nope for maximum path in graph .
Well, that is a lot more difficult. An algorithm for that does exist in a directed acyclic graph but I don’t know any for a general graph
wrong thread?