版本比较
# P8677 [蓝桥杯 2018 国 A] 采油 题解
正文
增加 2 行删除 2 行
18 行未改动1920212223232425262736 行未改动6465666768686970717239 行未改动18 行未改动先递归自己的每棵子树,将它化为一个“油田”,并将它们的 $ B $ 和 $ S $ 记到数组(我用的 vector)中,便于接下来排序。
```cppfor (int i=head[u];i;i=e[i].nex){ { if (e[i].to==fa) continue; //防止走回父节点 func(e[i].to,u); a[u].push_back(a[e[i].to][0]);}36 行未改动void func(int u,int fa){ int ansc=0; for (int i=head[u];i;i=e[i].nex) { { if (e[i].to==fa) continue; func(e[i].to,u); a[u].push_back(a[e[i].to][0]); }39 行未改动