• [1327] Advance Bravely

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Remember the defeated demons? the survivals go back and told the big boss, big boss was so angry that he decide to fight TT back. The big boss used his strong power and made many roads, TT and her army was in point 1, big boss was in point N. TT wanted to go as quickly as possible to defeat the boss, let's find out the proper way to go.
  • 输入
  • For each case, there was two integers N and M, big boss was in N(1 <= N <= 100), and there are M(1 <= M <= 2000) roads. then M lines followed. The ith line contains X,Y,dis,means that road X to road Y's distance is dis. there is no any other roads if not given.
  • 输出
  • For each case, output the shortest distance from 1 to N.
  • 样例输入
  • 6 6
    1 6 20
    2 1 4
    3 6 6
    4 2 14
    4 5 16
    4 6 8
    5 3
    1 4 16
    2 5 2
    4 5 2
    
  • 样例输出
  • 20
    18
  • 提示
  • 来源
  • Mr.Cai
  • 操作

显示春菜