Directed unweighted graph is given with the list of edges. Let dist[u] contains the shortest path from vertex v = 5 to t
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Directed unweighted graph is given with the list of edges. Let dist[u] contains the shortest path from vertex v = 5 to t
Directed unweighted graph is given with the list of edges. Let dist contains the shortest path from vertex v = 5 to the vertex u. If there is no path from v = 5 to u, set dist = -1. Find the sum of the values dist[1] + dist[2] + ... + dist[n] (graph contains n vertices, numbered from 1 to n). Input The first line contains the number of vertices. Each next line contains an edge. Output Print the sum of the values dist[1] + dist[2] + ... + dist[n], whre n is the number of vertices. Sample input 6 53 32 Sample output 5 6 start Activate Windows