11924 - Shorest Paths (edge+vertex version)   

Description

這題不是作業!
作業在 https://acm.cs.nthu.edu.tw/problem/11922

  • Given
    • A matrix of digits
  • Task
    • Convert the nonzero digits of the matrix into a graph
    • The nonzero digits represent the edge cost of edges between two vertics
    • Find the shortest path between all pairs of vertics
    • Print out the cost of shortest (lowest-cost) paths for each vertex pair (只需印 cost,不用印 path)
    • Here path cost includes edges and vertics

Input

Matrix Specification

  • Each cell in the matrix contains a digit value (ranged from 0 to 9)
    • 0 represents no edge between two vertics
    • Nonzero digits represents the weights of two vertics
    • 100≥ Number of vertices (i.e., matrix width and height) ≥2

Output

Print out the cost of shortest paths with row major order for each pair

Sample Input  Download

Sample Output  Download

Tags




Discuss