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

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

How to solve this problem

I can't figure out the approach.Describe the approach in details please. Thanks in advance

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

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

First step, sort the edges according to weight. Second step, sort the query. Third step firstly takes the higher or equal weighted edges of the highest value of the query. then connect them through disjoint set union. here you can find the solution for the highest value of the query. In this way, by adding the edges according to the value of decreasing query you will get all solutions of the query.