最近在練樹形 DP,正好看到 這一道 虛標的紫題,但本蒟蒻不會寫,想出來了便記錄一下 題面 & 思考 先看題面,一顆有根樹,選定 k 個節點作為 ”伐木場“,求運送木料最小費用。注意木料費用是 dis * wood 。 最開始想到簡單的樹形揹包,狀態轉移方程: 1 f[i][k] = min (f[j][s] + cost, f[i][k]); 但是注意到,如果某個後代節點如果是伐木場,cost …
Louis Aeilot's Blog 的其他文章
- How Close Is FlashAttention to the Limit? Understanding Attention Through Data Movement
- Beyond FLOPs: How COSMA Builds Parallel Matrix Multiplication from Communication Bounds
- The Red-Blue Pebble Game: Why Faster Processors Still Have to Move Data
- Git Needs a Trash Can
- RoPE: Properties, Patterns, and Long-Context Behavior
讨论
登录后参与讨论
还没有评论,来说第一句吧。