my code is giving WA . Pls suggest error in approach.
Link—https://ide.codingblocks.com/s/162249
Amit and Tree--needed help
In your code while taking the input of the edges. Why haven’t you taken the weight of the edge.
9
88 22 83 14 95 91 98 53 11
2 3 24
3 7 -8
4 1 67
5 1 64
6 9 65
7 5 12
8 6 -80
9 3 8
There are 3 numbers ui
, vi
, and ci
describing an edge b/w ui
and vi
with a weight ci
.
The code for the input should be following.
ll u, v, c;
for(ll i=1;i<=n-1;i++){
cin>>u>>v>>c;
adj[u].push_back({v,c});
}
I have corrected it but still it’s showing wrong answer . pls help.link—https://ide.codingblocks.com/s/162457
You didn’t initialise the visited array. Make the visited array of type bool. And initialise it with false.
still giving wrong answer