CF1184E2 Daleks' Invasion (medium)
Description
After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the current Daleks' plan – which is to use a minimum spanning tree of Corridors. Heidi knows that all energy requirements for different Corridors are now different, and that the Daleks have a single unique plan which they are intending to use.
Your task is to calculate the number $ E_{max}(c) $ , which is defined in the same way as in the easy version – i.e., the largest $ e \le 10^9 $ such that if we changed the energy of corridor $ c $ to $ e $ , the Daleks might use it – but now for every corridor that Heidi considers.
Input Format
N/A
Output Format
N/A
Explanation/Hint
If $ m = n-1 $ , then you need not output anything.