Getting WA on both test cases

sample cases are passing but getting WA on both Test cases
PLZ HELP

@Akshay123
There are few mistakes in the code. I am pointing out them, please correct them

  1. It’s an undirected graph, so after line 70 write g.addedge(y,x);
    2)Change line 31 to if(dist[nbr]==-1 || (dist[nbr]>dist[node]+1))

Still getting WA- https://ide.codingblocks.com/s/231018 PLZ HELP

@Akshay123
bro after line 71, write g.addedge(y,x);
It is undirected graph

Sorry my fault, edited line 11 but with u instead of v, now getting AC!!

what effect it would have if I had used dijstra instead of BFS??

@Akshay123
:grinning: Is dijsktra different from what you did here? I think it’s same. BFS is searching method used in dijskra algorithm

Ohh yeah right, actually true :slight_smile:

1 Like