Educational Round Problem

Revision en2, by notking, 2018-06-29 16:52:17

Hello guys

I was trying to solve problem E from last CF round and I got the idea that we can make a bridge tree(compress unbridged-connected nodes into a single node) and then find the diameter of the tree.

I saw some solutions that first find the nodes and compress them and then new dfs to find diameter as usual but I saw the shortest codes submitted and was amazed to see that it just contained a single dfs and was very neat.

I have two questions. Firstly how does this code work without actually finding diameter and how do people come up with such implementation? Do they first think about the whole implementation which is shortest and then code?

Tags solution, implementation, shortcode

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English notking 2018-06-29 16:52:17 22
en1 English notking 2018-06-29 15:32:01 793 Initial revision (published)