I was solving BUGLIFE.
My code : https://ideone.com/Y2jdyz
Why is this not passing the test cases? Can someone please tell where I made an error in my code?
I was solving BUGLIFE.
My code : https://ideone.com/Y2jdyz
Why is this not passing the test cases? Can someone please tell where I made an error in my code?
Fill vis
and col
with 0s.
memset(vis, 0, sizeof(vis));
memset(col, 0, sizeof(col));
And why are you clearing only the ith adjacency list?
Oh yeah I forgot that
I forgot to add a loop actually, thanks a lot
Why are you running dfs
before you’ve even finished reading in the edges?
Edit:
Also, review the Output format carefully.
Edit2:
Yet another example of where the simple act of having your Editor indent your code would make a bug immediately obvious - why won’t people do this??? XD
How many adjaceny lists are there? How many are you clearing?
Also, your variable names are terrible. It is hard for us to debug.
Debugged, new code : https://ideone.com/Ubd5a4
Passes test cases, but gives WA. Where am I going wrong?
Going to go ahead and mention that the whole “global adjacency lists are a terrible, error-prone idea” yet again, but people seem to be bewilderingly keen on using them, so
Got AC. Thanks @ssjgz @therealnishuz
My code : https://ideone.com/leDwOd (Just in case anyone wants)