0w1

Entries from 2016-04-03 to 1 day

CFR 219 D. Choosing Capital for Treeland ( Tree DP )

Problem - D - Codeforces 搞了很久才弄出來。。首先要分成兩種邊,一種是順向邊,輸入給定的邊,一種是逆向邊,就是要經過反轉才能用的邊。這麼一來,我們可以先透過一次深搜得到隨便一個點當根的時候的花費。顯然我們不能暴力對所有根重新計算,但我們可以…

CFR 437 D. The Child and Zoo ( Union Find )

Problem - D - Codeforces 顯然如果要從一個點到另一個點的路徑中最小權值最大,一定要沿著瓶頸生成樹走。圖裡的邊以兩端的最小值描述。很容易發現,越大的邊越有機會帶來影響,而某個邊有影響若且為若它是能將兩個無法相互到達的塊連通的邊裡邊權最大,並且…

CFR 245 1A. Xor-tree ( Greedy + DFS )

Problem - 429A - Codeforces It is obvious that if all nodes above are cleared and the current node is not the target, it has to be flipped. It is never better to flip its ancestors, for it will cost extra for nothing. We don't have to go d…

GCJ 2014 R1A pB. Full Binary Tree ( DFS )

Dashboard - Round 1A 2014 - Google Code Jam 題目中一個合法的完全樹的定義是,所有節點的子節點數為0或2。要求的是移除最少點使得給定的樹成為完全樹。因為數據範圍小,可以考慮枚舉每個節點作為根,再做一次線性的深搜處理。根據定義可以得到遞迴函數,…