HUD 5438 Ponds
Solution Sketch
Key: Use DFS and yank nodes with $total\ degree = 1$
Never give up!
在樹上做DP,基本上是挑一個點當作 root 開始 DFS。維護 連同節點$u$在內已經拜訪過的子樹結點總數 和 拔掉節點$u$後最大的子數大小,就可以求出答案。
Let the source node be $0$, shirt nodes from small to large are $[1, 6]$ respectively, participant nodes are $[7, 7 + n)$, and sink node be $7 + n$.
Construct the flow graph with 1 super source, 10000 time nodes, n dish nodes, and 1 super sink.
Connect super source to all time nodes with cap 1. Connect dish’s time $[a_i, b_i)$ to dish’s node, with cap 1. Connect all dish nodes to the super sink with cap value from binary search.