A project has n tasks with durations in days, and m dependencies u v meaning "task u must finish before task v starts" (a weighted DAG). Write ProjectSchedule: process the tasks in topological order (Kahn's algorithm with a queue); the earliest start of a task is the latest finish among its prerequisites.
Input: n m, then n lines name duration, then the m dependencies (task numbers from 0). Print each task's start and finish day, the project length and the critical path — the chain of tasks that determines that length. If the dependencies contain a cycle, print The dependencies contain a cycle: no schedule exists.
For the input
6 6
Design 3
Backend 5
Frontend 4
Database 2
Testing 3
Launch 1
0 1
0 2
0 3
1 4
2 4
4 5
the program prints
Design: day 0 to day 3
Backend: day 3 to day 8
Frontend: day 3 to day 7
Database: day 3 to day 5
Testing: day 8 to day 11
Launch: day 11 to day 12
Project length: 12 days
Critical path: Design -> Backend -> Testing -> Launch