Getting WA in HDELIVER

What is wrong with my implementation of HDELIVER?

Code : http://www.codechef.com/viewsolution/3934828

Initially I got TLE but after using better implementation, I am getting Wrong Answer.

this is mostly one of the errors…

you are not marking the current element i.e. the kth element as visited as not marking its color!!!

this should be added

color[k]=iter;

EDIT 1:

w/o that try putting this case u will get all ans as YO but it should be NO…

1
4 0
3
0 2
0 3
2 1

EDIT 2:

this is ur corrected code…LINK…hope u r able to understand what mistake u were making…else feel free to ask…:slight_smile:

1 Like

Thanks a lot bro for helping me. Now I have solved my first graph theory problem.

1 Like
//