結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー h_nosonh_noson
提出日時 2017-06-15 23:49:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 677 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 94,944 KB
最終ジャッジ日時 2023-10-25 07:58:12
合計ジャッジ時間 22,350 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,192 KB
testcase_01 AC 29 ms
10,192 KB
testcase_02 AC 33 ms
10,192 KB
testcase_03 AC 34 ms
10,240 KB
testcase_04 AC 30 ms
10,192 KB
testcase_05 AC 30 ms
10,240 KB
testcase_06 AC 30 ms
10,236 KB
testcase_07 AC 30 ms
10,240 KB
testcase_08 AC 31 ms
10,236 KB
testcase_09 AC 31 ms
10,240 KB
testcase_10 AC 31 ms
10,240 KB
testcase_11 AC 30 ms
10,240 KB
testcase_12 AC 30 ms
10,240 KB
testcase_13 AC 31 ms
10,240 KB
testcase_14 AC 44 ms
10,964 KB
testcase_15 AC 44 ms
10,980 KB
testcase_16 AC 43 ms
10,984 KB
testcase_17 AC 43 ms
10,980 KB
testcase_18 AC 45 ms
10,984 KB
testcase_19 AC 45 ms
10,976 KB
testcase_20 AC 45 ms
10,984 KB
testcase_21 AC 45 ms
10,968 KB
testcase_22 AC 44 ms
10,964 KB
testcase_23 AC 46 ms
10,976 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 31 ms
10,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def dfs(u,cp):
    cp[u] = True
    for v,c in re[u]:
        if not cp[v] and t[v] + c == t[u]:
            dfs(v,cp)

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)
cp = [False] * n
dfs(n-1,cp)
print(t[n-1],"%d/%d" % (n-sum(cp),n))
0