結果
問題 | No.30 たこやき工場 |
ユーザー |
|
提出日時 | 2023-03-13 03:07:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 650 bytes |
コンパイル時間 | 534 ms |
コンパイル使用メモリ | 82,084 KB |
実行使用メモリ | 71,796 KB |
最終ジャッジ日時 | 2024-09-18 07:20:08 |
合計ジャッジ時間 | 2,141 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 6 |
ソースコード
from collections import dequen = int(input())m = int(input())g = [[] for _ in range(n)]deg = [0 for _ in range(n)]for _ in range(m):p, q, r = map(int, input().split())p -= 1r -= 1g[r].append((p, q))deg[p] += 1src = n - 1ans = [0 for _ in range(n)]ans[src] = 1used = [False for _ in range(n)]used[src] = Truedq = deque()dq.append(src)while len(dq) > 0:cur = dq.popleft()for nxt, cost in g[cur]:if used[nxt]:continueans[nxt] += ans[cur] * costdeg[nxt] -= 1if deg[nxt] == 0:used[nxt] = Truedq.append(nxt)if len(g[cur]) > 0:ans[cur] = 0ans.pop()print(*ans, sep="\n")