結果

問題 No.30 たこやき工場
ユーザー convexineqconvexineq
提出日時 2021-01-15 09:06:32
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 76,284 KB
最終ジャッジ日時 2023-08-23 05:23:42
合計ジャッジ時間 2,468 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
70,840 KB
testcase_01 AC 76 ms
71,140 KB
testcase_02 AC 74 ms
70,996 KB
testcase_03 AC 76 ms
70,948 KB
testcase_04 AC 74 ms
70,948 KB
testcase_05 AC 75 ms
70,784 KB
testcase_06 AC 75 ms
71,244 KB
testcase_07 AC 73 ms
71,292 KB
testcase_08 AC 73 ms
71,092 KB
testcase_09 AC 75 ms
70,928 KB
testcase_10 AC 86 ms
76,284 KB
testcase_11 AC 75 ms
70,972 KB
testcase_12 AC 73 ms
71,096 KB
testcase_13 AC 74 ms
71,224 KB
testcase_14 AC 74 ms
71,208 KB
testcase_15 AC 75 ms
71,148 KB
testcase_16 AC 76 ms
71,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,*P = map(int,open(0).read().split())
g = [[] for _ in range(n)]
ind = [0]*n
for i in range(0,3*m,3):
    g[P[i+2]-1].append((P[i]-1,P[i+1]))
    ind[P[i]-1] += 1
dp = [0]*n
dp[-1] = 1
*q, = [i for i in range(n) if ind[i]==0]
for i in q:
    for c,d in g[i]:
        dp[c] += dp[i]*d
        ind[c] -= 1
        if ind[c]==0: q.append(c)
    if g[i]: dp[i]=0
print(*dp[:-1],sep="\n")
0