E. pashmak and Graph
Pashmak's homework is a problem about graphs. although he always tries to do his homework completely, he can't solve this problem. as you know, he's really weak at graph theory; so try to help him in solving the problem.
You are given a weighted directed graphNVertices andMEdges. you need to find a path (perhaps, non-simple) with maximum number of edges, such that the weights of the edges increase along the path. in other words, each edge of the path must have strictly greater weight than the previous edge in the path.
Help pashmak, print the number of edges in the required path.
Input
The first line contains two integersN,M(2 cores ≤ CoresNLimit ≤ limit 3 · 105; 1 limit ≤ limitMLimit ≤ limitMin(N·(NInterval-interval 1), interval 3 · 105). Then,MLines follows.I-Th line contains three space separated integers:UI,VI,WI(1 digit ≤ DigitUI, Bytes,VILimit ≤ limitN; 1 bytes ≤ bytesWILimit ≤1_105) which indicates that there's a ccted edge with weightWIFrom VertexUITo VertexVI.
It's guaranteed that the graph doesn't contain self-loops and multiple edges.
Output
Print a single integer-the answer to the problem.
Question: Find the longest path of the monotonically unchanged path weight for a given graph.
SL: sort the order directly, and then run DP. Each edge is equivalent to a restriction. But note that the records with the same length will not be updated, so it is better to open an array of records.