report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
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 ```
DAG / Topological sort
DAG
Reading order
Longest path
Maximum path
Martian language
Edge direction
Train pass
Topic
Graph
Dynamic Programming
Rating 1400
Solution (1) Solution