strange14's blog

By strange14, history, 2 years ago, In English

My solution involving prim's algorithm 145857604 gives wrong answer for this problem : 1513D - GCD and MST I understand the Kruskal's algorithm solution mentioned in the editorial, but cannot figure out why prims is failing here.

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Try this testcase:

1
3 1000
6 3 2

Correct answer :- 1003