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

Автор kanisht_09, история, 6 лет назад, По-английски

Please can someone help me this problem :

https://www.spoj.com/problems/BUGLIFE/

I am getting wrong answer when I m changing the color explicitly i.e before calling dfs here is the code : Your text to link here...

And i got AC when I send the color along with dfs function Your text to link here...

if u look at both the codes dont u think they are equivalent? If not please tell me which edge case am i missing? Thanks in advance :)

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

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

For easy test:

1
3 2
1 2
1 3

There you do recursion from 1. You are coloring node 1 with color 0. For neighbor 2 you change color to 1. For neighbor 3 you change color back to zero. There you recognize error although there is none.