Skip to content

Commit

Permalink
fixed bug in dijkstra
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoskolodny committed Jul 4, 2019
1 parent aabcba1 commit 359b098
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion graphs/dijkstra.cpp
Expand Up @@ -8,7 +8,7 @@ void dijkstra(int x){
x=q.top().snd;ll c=-q.top().fst;q.pop();
if(dist[x]!=c)continue;
fore(i,0,g[x].size()){
int y=g[x][i].fst,c=g[x][i].snd;
int y=g[x][i].fst; ll c=g[x][i].snd;
if(dist[y]<0||dist[x]+c<dist[y])
dist[y]=dist[x]+c,q.push(mp(-dist[y],y));
}
Expand Down
2 changes: 1 addition & 1 deletion graphs/dijkstra_test.cpp
Expand Up @@ -21,7 +21,7 @@ void dijkstra(int x){
x=q.top().snd;ll c=-q.top().fst;q.pop();
if(dist[x]!=c)continue;
fore(i,0,g[x].size()){
int y=g[x][i].fst,c=g[x][i].snd;
int y=g[x][i].fst; ll c=g[x][i].snd;
if(dist[y]<0||dist[x]+c<dist[y])
dist[y]=dist[x]+c,q.push(mp(-dist[y],y));
}
Expand Down

0 comments on commit 359b098

Please sign in to comment.