Look before solve


#1
  1. Run Dijkstra’s on C.
  2. Maintain distance array (dist[])
  3. It is mentioned that edges of ‘B’ are directed but it is undirected.
    Ex.
                    1
                   /  \
                 2    3
               /  \
              4    5
       Here, there is not path possible between 3 and 5, if the edges are directed.
  1. For every edge, check whether nodes or vertex of a edge is in range or not (1 <= node <= A).
  2. Iterate the E and for each edge in E, check for (dist[from] - dist[to] ) < E[2], if yes.

#2

No. B is directed edges, E is an undirected edge. So E (3,2) will form an undirected edge between 3 and 2, through which u can move to 5.