結果

問題 No.30 たこやき工場
ユーザー rlangevinrlangevin
提出日時 2023-09-12 08:54:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 419 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 98,924 KB
最終ジャッジ日時 2023-09-12 08:54:56
合計ジャッジ時間 7,394 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
13,692 KB
testcase_01 AC 18 ms
8,516 KB
testcase_02 AC 18 ms
8,532 KB
testcase_03 AC 19 ms
8,552 KB
testcase_04 AC 18 ms
8,436 KB
testcase_05 AC 18 ms
8,532 KB
testcase_06 AC 19 ms
8,600 KB
testcase_07 AC 18 ms
8,564 KB
testcase_08 AC 348 ms
9,228 KB
testcase_09 AC 19 ms
8,532 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
M = int(input())
G = [[] for i in range(N)]
for i in range(M):
    p, q, r = map(int, input().split())
    p, r = p - 1, r - 1
    G[r].append((p, q))

Q = deque([N - 1])
ans = [0] * N
ans[-1] = 1
while Q:
    u = Q.popleft()
    for v, c in G[u]:
        ans[v] += ans[u] * c
        Q.append(v)
    if len(G[u]):
        ans[u] = 0

for i in range(N - 1):
    print(ans[i])
0