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

Автор xennygrimmato, 11 лет назад, По-английски

For a problem that I am solving, I need to sort in descending order all edges by weight and keep removing edges till the graph becomes disconnected.

I am performing DFS after removing every edge, to check if the graph is disconnected. So, the time complexity of this method is O(NM).

Is there any way in which I can perform the above task faster?

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

»
11 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +18 Проголосовать: не нравится

Sort the edges in ascending order, then start adding edges to your graph until it becomes connected. You can use dsu for it. The total running time will be O(MlogM + Mα(N)).

Edit. This solution may be wrong, I think I'm missing something important and came too fast to a conclusion.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Binary search?

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +28 Проголосовать: не нравится

pls dont violate the rules of a running contest

http://www.codechef.com/APRIL15/problems/DIVLAND