Longest path - MarisaOJ: Marisa Online Judge

Longest path

Time limit: 1000 ms
Memory limit: 256 MB
Given an directed acyclic graph (DAG), find the longest path on the graph. ### Input - The first line contains two integers $n,m$. - The next $m$ lines, each line contains two integers $u, v$ an edge directed from $u$ to $v$. ### Output - Print the length of the longest path. ### Constraints - $1 \le n,m \le 10^5$. - $1 \le u,v\le n$. ### Example Input: ``` 3 3 1 2 2 3 1 3 ``` Output: ``` 3 ```