結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー yuppe19 😺
提出日時 2016-12-18 18:57:08
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 845 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 76,452 KB
実行使用メモリ 251,592 KB
最終ジャッジ日時 2024-12-14 08:33:42
合計ジャッジ時間 38,604 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 21 TLE * 10
other AC * 5 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
n, m = map(int, raw_input().split())
G0 = []
rG = []

for _ in xrange(m):
    a, b, c = map(int, raw_input().split())
    G0.append([a, b, -c])
    rG.append([b, a, -c])

cost0 = [1] * n # cost0[n]
cost0[0] = 0
while True:
    update = False
    for e in G0:
        if cost0[e[0]] != 1 and cost0[e[1]] > cost0[e[0]] + e[2]:
            cost0[e[1]] = cost0[e[0]] + e[2]
            update = True
    if not update:
        break
days = -cost0[n-1]

rcost = [1] * n
rcost[n-1] = 0
while True:
    update = False
    for e in rG:
        if rcost[e[0]] != 1 and rcost[e[1]] > rcost[e[0]] + e[2]:
            rcost[e[1]] = rcost[e[0]] + e[2]
            update = True
    if not update:
        break

cnt = sum(-cost0[i] != days + rcost[i] for i in xrange(n))
print '{} {}/{}'.format(days, cnt, n)
0