Блог пользователя iamdumb

Автор iamdumb, 10 лет назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.