ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1709. Penguin-Avia

Hint
Posted by Frankey 26 Jul 2009 21:25
This is very easy problem. You can use:
1) BFS or DFS to find the components of the graph;
2) Prim or Kruskal algo for minimum spanning tree.
Re: Hint
Posted by SkorKNURE 26 Oct 2010 16:28
spanning tree can be built during BFS. It's correct because graph is unweighted.
Re: Hint
Posted by Artem Khizha [DNU] 16 Jul 2011 17:22
Well, I see, that this is MST problem, but cannot get how to build a graph for it. Please, explain your step 1 more precisely.
Re: Hint
Posted by Sehriyar Novruzov 28 Jul 2015 17:56
Sure, it can be solved applying BFS or DFS + Minimum Spanning Tree algorithms (Prim Algorithm). But, BFS or DFS is enough to solve it. BFS or DFS is implemented to identify Connected Component and Non-Connected Component. No need to apply MST to remove redundant edges in each Connected Component. Because, while BFS or DFS you can built identify which edges you need and don't need. Here is one part of my code to do BFS and work like Prim algo

[code deleted]

Edited by moderator 19.10.2019 20:33