PLs someone find the error in my code…
Can u pls find the error
It’s showing segmentation fault
please share ur logic that u are trying to apply
it seems there are short comming in logic
once u explain i`ll tell u where ur logic lags
u can either make a road or temple if cost of road is greater then temple then it is easy to make temple rather than road
but if road cost is less then temple then u need to find where temple can be make and how many different cities are connected to it
like ex
1 2
2 3
3 4
5 6
temple cost 5 road cost 2
so u can make temple in city 1 and city have path to city 1 are 2 ,3 and 4
so cost =5+2*3=11
also u have to make temple at city 5 as no path b|w city 1 and 5
but city 6 is connect to 5
so cost=5+2=7
total=18
Basically u have to find component of graph
this is the logic i am applying
ur logic is perfect i`ll debugg the code
thnx in advance…
i have updated the code
segmentation fault was because of the size of vector g
and u were missing the case when temple cost less than road
also
for eg
3 1 2 1
1 2
like there are 3 nodes but we are given details about 1 edges connecting 1 ->2 2->1
here node 3 was not beinf counted in ur code
line no 9 does that for u( inupdated code)
yeah i got the error…thnx…