{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e给定一个有向图,图中有 $$$n$$$ 个顶点和 $$$m$$$ 条边,所有边都有一定的权重。\u003c/p\u003e\n\u003cp\u003e图中可能存在多条边和自环,图也可能是不连通的。\u003c/p\u003e\n\u003cp\u003e你需要在图中选择一条路径(可能多次经过相同的顶点),使得边的权重严格按照递增顺序排列,并且这些边按照输入的顺序出现。在所有这样的路径中,你需要找到包含最大边数的路径,并报告最大边数。\u003c/p\u003e\n\u003cp\u003e请注意,选择的边在输入中不必是连续的。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含两个整数 $$$n,m$$$ ($$$1 \\leq n,m \\leq 10^5$$$),分别表示图中的顶点数、边数。\u003c/p\u003e\n\u003cp\u003e接下来 $$$m$$$ 行,第 $$$i$$$ 行包含三个整数 $$$a_i,b_i,w_i$$$ ($$$1 \\leq a_i,b_i \\leq n$$$,\u0026nbsp;\u0026nbsp;$$$0 \\leq w_i \\leq 10^5$$$),表示从顶点 $$$a_i$$$ 到顶点 $$$b_i$$$ 的边,权重为 $$$w_i$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e在一行中打印一个整数,表示路径中的最大边数。\u003c/p\u003e"}},{"title":"示例1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 3\n3 1 3\n1 2 1\n2 3 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"示例2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 5\n1 3 2\n3 2 3\n3 4 5\n5 4 0\n4 5 8\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e第一个示例输入的答案是 2: $$$1 \\rightarrow 2 \\rightarrow 3$$$。请注意,你不能遍历 $$$1 \\rightarrow 2 \\rightarrow 3 \\rightarrow 1$$$,因为边 $$$3 \\rightarrow 1$$$ 在输入中出现的时间早于另外两条边,因此无法在选择另外两条边之后才被选择/遍历。\u003c/p\u003e\n\u003cp\u003e在第二个示例中,最优选择是选择第 $$$1$$$、第 $$$3$$$、第 $$$5$$$ 条边,得到最优答案:$$$1 \\rightarrow 3 \\rightarrow 4 \\rightarrow 5$$$。\u003c/p\u003e"}}]}