結果
問題 |
No.30 たこやき工場
|
ユーザー |
|
提出日時 | 2019-08-25 21:56:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 719 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 189,856 KB |
最終ジャッジ日時 | 2024-11-07 01:50:09 |
合計ジャッジ時間 | 7,418 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 6 |
ソースコード
from collections import deque import sys input = sys.stdin.readline def bfs(): queue = deque([]) queue.append(N-1) need = [0] * N need[N-1] = 1 while len(queue) > 0: current_node = queue.popleft() for next_node, w in adj_list[current_node]: need[next_node] += w * need[current_node] queue.append(next_node) if len(adj_list[current_node]) != 0: need[current_node] = 0 return need N = int(input()) M = int(input()) adj_list = [[] for _ in range(N)] for _ in range(M): Pi, Qi, Ri = map(int, input().split()) adj_list[Ri-1].append((Pi-1, Qi)) need = bfs() for need_i in need[:-1]: print(need_i)