Syntax error leading to segmentation fault


I’m not able to figure out what is it that I’m doing wrong. Please help asap!

Updated code : https://ide.codingblocks.com/s/323853

@sufia.aleena12 your adj is empty so while doing adj[x] it will give segmentation fault

@vatsal38 but we are using 1 based indexing. Even if I do adj[0].push_back({0, 0}) before taking the inputs (i.e. after line 51), I still end up getting the same error

@sufia.aleena12 you have only declared adj it contains no space so if you do a[0] it will give segment
you can use array of vectors then it should work

@vatsal38 Updated code : https://ide.codingblocks.com/s/324458
Not getting correct answers now!

@sufia.aleena12 I think you have send some wrong code it contains csum and all

Here it is

@sufia.aleena12

I think your solution is incorrect because the diagonal elements should be zero always.
Kindly check my solution.

@sufia.aleena12 explain your logic a little bit
but for simple explanation and code refer this

@vatsal38 I followed exactly the same approach as in the video. But since the input is in 1 based indexing, I’m facing an issue. My logic is correct though. Upon dry running I don’t get wrong asnwers. Only the indexing is an issue.

@sufia.aleena12


replace int_max with 99999
(bvasically smaller ke saath)

Nothing has changed here. Only that we are storing 99999 initially instead of INT_MAX.
Actually the output should be :
0 3 4 4
3 0 1 1
4 1 0 2
4 1 2 0

@sufia.aleena12 if you want output at bhs just make edge from y to x too here refer this


just added 1 line

Such a silly mistake :sweat_smile: Thanks a lot

@sufia.aleena12 you are welcome :grinning:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.