HDU - Fibonacci Tree Problem in short: Given some black and white edge, you need to check if there exists a spanning tree where the number of the white nodes is a Fibonacci number. Idea: Count the number of maximum needed white edge to form a spanning tree. Let it be need_mx. Count the number of minimum needed white edge to form a spanning tree. Let it be need_mn . If there exists a Fibonacci number between [ need_mn , need_mx ] then there exists a spanning tree where the number of the white nodes is a Fibonacci number. Check if the graph is connected or not. To get need_mx we first consider all edges with white color. And for need_mn first consider all edge with black color. We can do this easily with Kruskal's algorithm. Code
Posts
Showing posts from July, 2018