結果
問題 |
No.30 たこやき工場
|
ユーザー |
|
提出日時 | 2020-10-27 08:03:48 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 76,032 KB |
最終ジャッジ日時 | 2024-07-21 21:50:54 |
合計ジャッジ時間 | 7,555 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 6 |
ソースコード
from collections import deque N = int(input()) M = int(input()) P = [{'no': n, 'parents': [], 'children': set(), 'items': 0} for n in range(N)] P[N - 1]['items'] = 1 for _ in range(M): p, q, r = map(int, input().split()) P[r - 1]['parents'].append((p - 1, q)) P[p - 1]['children'].add(r - 1) visited = set() # dfs d = deque([P[N - 1]]) while d: product = d.pop() if product['children'] <= visited: visited.add(product['no']) if product['parents']: for parent, q in product['parents']: P[parent]['items'] += q * product['items'] d.append(P[parent]) product['items'] = 0 for n in range(N - 1): print(P[n]['items'])