ICPC trip question

if the edges are directed can we use this method or we have to apply djikstra from all nodes

Yes we can use this method. No you don’t need to apply Dijkstra’s algo from every node.