結果

問題 No.30 たこやき工場
ユーザー mkawa2mkawa2
提出日時 2020-01-06 12:47:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 544 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2024-05-02 10:49:13
合計ジャッジ時間 7,540 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,880 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 31 ms
10,624 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 32 ms
10,752 KB
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 138 ms
10,496 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from collections import *
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def main():
    def dfs(i, c=1):
        if not to[i]:
            ans[i] += c
            return
        for j, q in to[i]:
            dfs(j, c * q)
        return

    n = II()
    m = II()
    to = defaultdict(list)
    for _ in range(m):
        p, q, r = MI()
        to[r - 1].append([p - 1, q])
    ans = [0] * n
    dfs(n - 1)
    print(*ans[:-1], sep="\n")

main()
0