spoj buglife problem

i am not able to understand the problem can somebody explain me the question in proper way.
the link of question is http://www.spoj.com/problems/BUGLIFE/ thanks a lot in advance.

is this problem, you have to check if the graph is bipartite or not, and that is all.

If it is, answer is “no suspicious activity”, else the answer is the opposite.

The meaning of a bipartite graph -> GeeksForGeeks

to check it, just run a standard BFS.

label the source node(1st bug in this case) as 1, all the other nodes adjacent to it as 0, then all the others adjacent to these ones as 1 and so on…

each node should have the label “1-x” if x is the label of the parent of the node.

if at anytime, you encounter a node that has already been labelled, and its label does not match the one that you were going to assign it, then the answer is “suspicious activity found”.

1 Like

thanks @tanmay_sachan