• [1137] The Running Man

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • There is a running man running around the world.Now here are some places he will run to.Between two places exists distance.Now he is at A,he will go to B,C,D,E and else.
  • 输入
  • Input until EOF.
    Input a positive integer t(1<t<10) in the first line.t means the number of places(From A to (A+t-1)).
    Next line follows a integer n(1<n<20) means the existing loads.
    Then follows n lines.Each line includes three parameters x,y,z(0<z<100).It means the running man runs from place x to place y for z distance.and he can not run from place y to place x.If there is unspecified from x to y,it means he can not run directly from x to y.
  • 输出
  • You should output the minimum distance from starting point(place A) to every other places.If he can not go to place y,you should output 'No'.
  • 样例输入
  • 6
    7
    A B 7
    A C 15
    A D 3
    B C 4
    B D 6
    D E 5
    E C 2
  • 样例输出
  • A B 7
    A C 10
    A D 3
    A E 8
    A F No
    
    
  • 提示
  • 来源
  • hungar
  • 操作

显示春菜