vee_sharp's blog

By vee_sharp, history, 9 years ago, In English

Hello I am trying to solve the question :http://www.spoj.com/problems/PT07Z/ in SPOJ. I have used bfs to find the leaf node and then used bfs again to find the maximum path.I am trying this approach and I don't know what is causing the error. Here is a link to my solution http://ideone.com/QSJzDf.

  • 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

Your answer on this test is wrong. Paint this graph (at input section).
To solve this problem it is better to use "Adjacency lists", instead of "adjacency matrix". Your matrix g is too big and you create it using 8-bytes type "long long int" and on the stack.