my approach to this problem is:
1. build mst using prims
2. run a bfs from any special node to find the maximum edge between special nodes and that edge is the answer for all nodes.
my submission
my approach to this problem is:
1. build mst using prims
2. run a bfs from any special node to find the maximum edge between special nodes and that edge is the answer for all nodes.
my submission
Here is an issue:
UPD: the second one should be
conn[v].size()-1
(notu
), as I understood from your code. I've just tested it, but it still gives RTE, but on test 29.UPD2: the second RTE has just been solved. The issue was in using the same
pos
for bothu
andv
. The new verdict is WA on test 33. See my submissions for more details.