#C10180. Minimum Time to Complete Tasks
Minimum Time to Complete Tasks
Minimum Time to Complete Tasks
You are given n tasks and m dependency pairs. Each dependency is represented as a tuple \((u, v)\) meaning that task \(u\) must be completed before task \(v\) can start. Tasks are numbered from 1 to \(n\) and the dependency graph is guaranteed to be acyclic.
Your goal is to determine the minimum number of time units required to complete all tasks. Tasks that do not depend on each other can be executed in parallel (i.e. at the same time unit). The problem can be viewed as determining the longest path length in a directed acyclic graph.
inputFormat
The input is provided via standard input (stdin) and has the following format:
- The first line contains two integers \(n\) and \(m\), where \(n\) is the number of tasks and \(m\) is the number of dependency pairs.
- The next \(m\) lines each contain two integers \(u\) and \(v\) representing a dependency where task \(u\) must be finished before task \(v\) can start.
outputFormat
Output a single integer via standard output (stdout) representing the minimum time required to complete all tasks.
## sample5 4
1 2
1 3
3 4
2 5
3