title: Graph Algorithm / Disjoint Set
body: <p>I am trying to solve <a href="https://icpcarchive.ecs.baylor.edu/external/64/p6432.pdf" rel="nofollow">this problem</a> but unable to do it fast. </p>
  
  <p>In short - we have a graph (directed) and we want to find out from which node (a set of nodes to select from is given) we can visit the most nodes. A straightforward implementation will be to run DFS/BFS from every node and see how many we can visit. But that it too slow as there are over 5000 nodes in the graph. Running 5000 BFS/DFS will be take very long time.</p>
  
  <p>On the other hand I also get a feeling that this problem may have something to do with Disjoint Set data structure? But I am unable to formulate it that way as in my disjoint set implementation some of the mentioned rules.</p>
  
  <p>Can someone give a hint as to how to approach this problem?</p>