結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2020-01-06 15:14:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 38 ms / 5,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 220 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-12-21 05:29:00 |
合計ジャッジ時間 | 1,524 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
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(mi): dp[mi]=0 for pi,cnt in mtop[mi]: if dp[pi]==-1:dfs(pi) dp[mi]+=dp[pi]*cnt n = II() m = II() mtop=defaultdict(list) buy=[True]*n for _ in range(m): material, cnt, product = MI() mtop[material-1].append([product-1,cnt]) buy[product-1]=False dp = [-1] * n dp[n-1]=1 for i in range(n-1): if dp[i]!=-1:continue dfs(i) for i in range(n-1): if buy[i]:print(dp[i]) else:print(0) main()