CF960F Pathwalks

题目描述

给定 $n$ 个点 $m$ 条边的有向图,可能不连通,可能有重边,也可能会有自环。求最长的路径(可以经过重复节点),使得这条路径的编号和权值都**严格**单调递增,其中编号指输入的顺序。路径的长度是指经过边的数量。

输入格式

输出格式

说明/提示

The answer for the first sample input is $ 2 $ : ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/64f1808592d29bd3c0ddf93b30b30da2e43f461a.png). Note that you cannot traverse ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/701350564a202a853dc0a2e9276e318c9ca164a2.png) because edge ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/b59064b21bfeab8af7de18849682bc80881d0361.png) appears earlier in the input than the other two edges and hence cannot be picked/traversed after either of the other two edges. In the second sample, it's optimal to pick $ 1 $ -st, $ 3 $ -rd and $ 5 $ -th edges to get the optimal answer: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/da8446025ba10d3435163cc331ea49b0612f49e8.png).