Guest User

Untitled

a guest
Nov 28th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Q. You are given a directed weighted graph with n vertices. m pairs of vertices have 2 edges each, ie 2m edges. Each pair of vertex has 2 types of edge:
  2. 1. normal edge
  3. 2. special edge
  4.  
  5. You are also given a source S and a destination D. Find the shortest path from S to D using atmost 1 special edge.
  6.  
  7. example:
  8. S=1, D=3
  9. edge, normal, special
  10. 1->2, 10 9
  11. 2->3, 16 10
  12. in this example shortest path is 20 by taking special edge from 2->3
  13.  
  14. example 2
  15. S=1, D=3
  16. edge, normal, special
  17. 1->2, 10 15
  18. 2->3, 14 15
  19. ans = 24
Advertisement
Add Comment
Please, Sign In to add comment