結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー h_nosonh_noson
提出日時 2017-06-16 00:02:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 534 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 81,616 KB
実行使用メモリ 116,936 KB
最終ジャッジ日時 2023-10-25 07:59:45
合計ジャッジ時間 8,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,472 KB
testcase_01 AC 43 ms
55,472 KB
testcase_02 AC 41 ms
55,472 KB
testcase_03 AC 45 ms
55,472 KB
testcase_04 AC 41 ms
55,472 KB
testcase_05 AC 45 ms
55,472 KB
testcase_06 AC 44 ms
55,472 KB
testcase_07 AC 45 ms
55,472 KB
testcase_08 AC 45 ms
55,472 KB
testcase_09 AC 45 ms
55,472 KB
testcase_10 AC 46 ms
55,472 KB
testcase_11 AC 45 ms
55,472 KB
testcase_12 AC 46 ms
55,472 KB
testcase_13 AC 46 ms
55,472 KB
testcase_14 AC 89 ms
76,880 KB
testcase_15 AC 88 ms
76,740 KB
testcase_16 AC 88 ms
76,732 KB
testcase_17 AC 88 ms
76,796 KB
testcase_18 AC 86 ms
76,624 KB
testcase_19 AC 87 ms
76,716 KB
testcase_20 AC 86 ms
76,744 KB
testcase_21 AC 88 ms
76,892 KB
testcase_22 AC 89 ms
76,776 KB
testcase_23 AC 86 ms
76,740 KB
testcase_24 AC 524 ms
116,640 KB
testcase_25 AC 534 ms
116,680 KB
testcase_26 AC 529 ms
116,760 KB
testcase_27 AC 529 ms
116,708 KB
testcase_28 AC 522 ms
116,936 KB
testcase_29 AC 521 ms
116,736 KB
testcase_30 AC 511 ms
116,740 KB
testcase_31 AC 529 ms
116,764 KB
testcase_32 AC 522 ms
116,680 KB
testcase_33 AC 529 ms
116,668 KB
testcase_34 AC 205 ms
104,696 KB
testcase_35 AC 60 ms
65,128 KB
testcase_36 AC 42 ms
55,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,m = map(int,input().split(' '))
e = [[] for i in range(n)]
re = [[] for i in range(n)]
di = [0] * n
for i in range(m):
    a,b,c = map(int,input().split(' '))
    e[a].append((b,c))
    re[b].append((a,c))
    di[b] += 1
q = deque()
for i in range(n):
    if di[i] == 0:
        q.append(i)
t = [0] * n
while len(q):
    u = q.popleft()
    for v,c in e[u]:
        t[v] = max(t[v],t[u] + c)
        di[v] -= 1
        if di[v] == 0:
            q.append(v)
q = deque()
q.append(n-1)
cp = [False] * n
cp[n-1] = True
while len(q):
    u = q.popleft()
    for v,c in re[u]:
        if not cp[v] and t[v] + c == t[u]:
            cp[v] = True
            q.append(v)
print(t[-1],"%d/%d" % (n-sum(cp),n))
0