iamdumb's blog

By iamdumb, 10 years ago, In English

Hello guys,I was doing this graph theory problem which requires simple bfs.I have few issues with this hope you can help me out.

P.S-I have seen its solution on web and I cannot understand why we are doing bfs from every node?? And summing maximum of red and black everytime.Please see my solution v/s one i found on web.Thank you

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Here, what you need to do is divide all the fighters in two groups. So you can color them using black and red. It is obvious that fighters from same group wont fight. So fighters from red group will fight against only with fighters from black group and vice versa. Here, the list of rivals are given. So, if one is from red group then the other will be obviously from the black group. Start coloring them like this using bfs. At the end, you have two separate groups and you still don't know who are vampires and lykans. To know what is the maximum size of any group you just take maximum of red group and black group. That's it.