Problem link: http://www.spoj.com/problems/BUGLIFE/
My solution: http://code.geeksforgeeks.org/uLsQi4 uses bfs
I am using the colors 0 and 1 to color the graph and -1 for the vertices which are not yet discovered. But I am getting WA in the problem. Please help me out
EDIT:-
Used the loop for all the nodes and still getting WA.
Code at http://code.geeksforgeeks.org/vVfXkd