D. Edge Deletion
题意
the length of the shortest path from vertex 1 to vertex i as $d_i$ .
You have to erase some edges of the graph so that at most k edges remain. Let’s call a vertex i good if there still exists a path from 1 to i with length $d_i$ after erasing the edges.
Your goal is to erase the edges in such a way that the number of good vertices is maximized.
题解
先跑个最短路,再搜索,取最短路上的边。
代码
1 |
|
E. Vasya and a Tree
题意
给一颗树,将 v 和与 v 距离小于 d 的 v 的子节点的权值加上 x,输出所有节点的权值。
题解
保存每个点每次加权的终点和 x。
代码
1 |
|