WA in spoj BUGLIFE. Bipartite graph

Problem link: http://www.spoj.com/problems/BUGLIFE/

My solution:
Using bfs: http://ideone.com/IKJO4U
Using dfs: http://ideone.com/F9NXIe

Its a bipartite graph problem. I am using two numbers to color the nodes 1 and -1.
Getting WA,please let me know where I am doing it wrong.
Thanks!

1
6 5
1 2
2 3
4 5
5 6
4 6
The answer by your BFS implementation is wrong.

1 Like