結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-25 21:54:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 719 bytes |
| コンパイル時間 | 470 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 852,164 KB |
| 最終ジャッジ日時 | 2024-11-07 01:45:46 |
| 合計ジャッジ時間 | 6,013 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 MLE * 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)