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

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

Here is my sumbission on problem. I am getting WA on test8.What I do is I find all the incycle vertics and put them into set and then update the distances from it. Can anyone please point out the mistake in my code?

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

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

I haven't seen your code but there is an easier way. Just start processing from the leaves (nodes with degree 1). When you remove all such nodes, you get another set of leaves. Repeat this process. When you don't have any leaf remaining, that means only cycle vertices are left. Assign 0 to all of them and process the deleted nodes in reverse order of their deletion.

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

    There maybe many approaches to a single problem. I would like to know why is this particular approach wrong despite of its straightforwardness. Can you please help? Even I need help in this problem...My approach is similar to the one mentioned by vatsal :/