From feeca868433c711cba61b6043795222478e99e5b Mon Sep 17 00:00:00 2001 From: Nidheesh Pandey Date: Fri, 13 Oct 2017 21:25:53 +0000 Subject: [PATCH] Update Dijkstra.cpp --- Graph/Dijkstra.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Graph/Dijkstra.cpp b/Graph/Dijkstra.cpp index 448d4b500..844ad168f 100644 --- a/Graph/Dijkstra.cpp +++ b/Graph/Dijkstra.cpp @@ -1,5 +1,6 @@ #include using namespace std; +#define INF 10000010 vector < pair > graph[5*100001]; int m,n,l,x,y; int dis[5*100001]; @@ -27,6 +28,16 @@ int main() { graph[x].push_back(make_pair(l,y)); graph[y].push_back(make_pair(l,x)); } - dij(graph,1,dis); - + + scanf("%d",&s); + for(int i = 0;i < n;i++) + dis[i] = INF; + dij(graph,s,dis); + + for(int i = 0;i < n;i++) + if(dis[i] == INF) + cout<<"-1 "; + else + cout<