結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2025-02-06 22:08:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 100 ms / 5,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 1,114 ms |
コンパイル使用メモリ | 82,644 KB |
実行使用メモリ | 71,256 KB |
最終ジャッジ日時 | 2025-02-06 22:08:44 |
合計ジャッジ時間 | 2,966 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
N = int(input())M = int(input())E = [[] for _ in range(N)]D = [0] * Ndp = [0] * Nfor i in range(M):p, r, q = map(int, input().split())p -= 1q -= 1E[q].append((p, r))D[p] += 1Q = []for i in range(N):if D[i] == 0:Q.append(i)dp[N - 1] = 1while Q:x = Q.pop()for y, r in E[x]:D[y] -= 1dp[y] += r * dp[x]if D[y] == 0:Q.append(y)for i in range(N - 1):if len(E[i]) == 0:print(dp[i])else:print(0)