1. 程式人生 > >codeforce 1059E Split the Tree

codeforce 1059E Split the Tree

下意識 problem cnblogs 遠的 force 繼續 pro code log

題目http://codeforces.com/problemset/problem/1059/E

參考http://www.cnblogs.com/waldenlake/p/9750249.html

我也想到了貪心,從一個子葉a出發向上每一個都標記直至不滿足條件,但其實一個點是可以被重復標記的visit是可以被覆蓋的,總是下意識!visit,如果另一個子葉b向上爬得更遠的話,經過a和b的父親之後還能繼續向地上爬,這總是能滿足最優解。

codeforce 1059E Split the Tree