求助昨天cf div2 E的建图原理
  • 板块题目总版
  • 楼主Isaachsq
  • 当前回复4
  • 已保存回复4
  • 发布时间2021/4/5 08:45
  • 上次更新2023/11/5 01:01:36
查看原帖
求助昨天cf div2 E的建图原理
357161
Isaachsq楼主2021/4/5 08:45

https://www.luogu.com.cn/problem/CF1503C

下面是官方题解跑dijkstra的建图方式 不是很理解为什么这样建图就一定可以将最优解包括进来

Add the following edges:

ai→ai−1 with weight 0.

i→j with weight 0, where j is the largest index with aj−ai−ci≤0. The index j can be found with binary search.

i→j+1 with weight max(0,aj+1−ai−ci) where j is the same as before.

Every edge in this new graph corresponds to an edge in the original graph, and every edge in the original graph corresponds to a path in the new graph with at most the same cost. So the distance from a1 to an is preserved.

2021/4/5 08:45
加载中...