結果

問題 No.30 たこやき工場
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-12-31 11:56:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 70,656 KB
最終ジャッジ日時 2024-04-16 22:45:54
合計ジャッジ時間 1,895 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
54,016 KB
testcase_01 AC 42 ms
54,144 KB
testcase_02 AC 46 ms
53,632 KB
testcase_03 AC 42 ms
53,760 KB
testcase_04 AC 42 ms
53,888 KB
testcase_05 AC 42 ms
53,760 KB
testcase_06 AC 43 ms
53,888 KB
testcase_07 AC 44 ms
53,760 KB
testcase_08 AC 44 ms
54,656 KB
testcase_09 AC 45 ms
54,912 KB
testcase_10 AC 71 ms
70,656 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n = int(input())
m = int(input())
e = [[] for i in range(n)]
par = [0]*n
for i in range(m):
    p,q,r = map(int,input().split())
    e[r-1].append([p-1,q])
    par[p-1] += 1

q = deque([-1])
ans = [0]*n
ans[-1] = 1
while q:
    now = q.popleft()
    for nex,a in e[now]:
        ans[nex] += ans[now]*a
        par[nex] -= 1
        if par[nex] == 0:
            q.append(nex)

    if e[now]:
        ans[now] = 0
for i in ans[:-1]:
    print(i)
0