先缩点,对于缩完点后的DAG,可以直接在每个scc dfs一次就可以求出终点是这个scc的点的点对个数. # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vector> # include <queue> # include <stack> # include <map> # i…
题目说可以通过一条边多次,且点权是非负的,所以如果走到图中的一个强连通分量,那么一定可以拿完这个强连通分量上的money. 所以缩点已经很明显了.缩完点之后图就是一个DAG,对于DAG可以用DP来求出到达每一个点的money最大值.具体实现我用的是bfs. 然后如果一个强连通分量内有酒馆,那么这个点就可以更新答案啦. # include <cstdio> # include <cstring> # include <cstdlib> # include <iost…