Sir, i'm getting compilation error. please help me to figure out my mistake
i have removed all compilation error
-
s.insert(make_pair(dij_dist,ngr.first));
there should be a braces or use make_pair function
s.insert(make_pair({dij_dist,ngr.first}));
-
void addedge(int u, int v, int w ) {
m[x].push_back(make_pair(y,w));
m[y].push_back(make_pair(x,w));}
it should be x and y not u and v -
unordered_map(int ,int) dist ;
here you should use angular brackets
unordered_map<int ,int> dist ;
Modified Code
sir, i correct my code as u told. but still I’m getting compilation error. please check
sir, i did and got the correct output but failed in the test case. please help me to remove my error. here is my code -> https://ide.codingblocks.com/s/482594
you are missing one check
if((nodedist+ngr.second)<dist[ngr.first])
here you also have to check whether then ngr.first is processed befor or not
it should not be processed before
sir, Then how will i update the dist[ngr.first] if i get “if((nodedist+ngr.second)<dist[ngr.first])” ?
you can use visited map for that
but you have to check this condition also