You are given a Directed Acyclic Graph (DAG) with 'V' vertices, a list of 'E' directed edges, a source vertex src, and a destination vertex dest.
Your task is to count the total number of distinct paths from the src vertex to the dest vertex.
Input Format:
The first line of input contains four space-separated integers: 'V', 'E', src, and dest.
The next 'E' lines each contain two space-separated integers, u and v, representing a directed edge from vertex u to vertex v.
Output Format:
Print a single integer representing the total number of distinct paths from src to dest.
Note:
The graph is guaranteed to be a DAG, so there are no cycles.
The most efficient way to solve this is to use dynamic programming combined with a topological sort of the graph's vertices.
Let dp[i] be the number of paths from src to node i. The recurrence relation is dp[v] = sum(dp[u]) for all u that have an edge to v. We can compute this efficiently by processing the nodes in topological order.