因为是有向无环图,可以在拓扑图进行转移:https://ac.nowcoder.com/acm/contest/view-submission?submissionId=80404172