In the current article I will try to solve a problem for calculation of average distance with Dijkstra, given in codeforces.com contest here in pdf. What is the problem like? We have n weighted graphs like this: For each given graph,…