結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2022-02-13 15:40:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-29 05:37:15 |
合計ジャッジ時間 | 1,465 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
from sys import setrecursionlimitsetrecursionlimit(10**6)def dfs(pos):if cnt[pos] != -1:return cnt[pos]ret = 0for nxt,Q in G[pos]:ret += dfs(nxt) * Qcnt[pos] = retreturn retN = int(input())M = int(input())G = [[] for _ in range(N)]Rev = [True] * Nfor _ in range(M):P,Q,R = map(int,input().split())P -= 1R -= 1G[P].append((R, Q))Rev[R] = Falsecnt = [-1] * Ncnt[N-1] = 1for i in range(N-1):if Rev[i]:dfs(i)for i in range(N-1):if not Rev[i]:cnt[i] = 0print(cnt[i])