結果

問題 No.30 たこやき工場
ユーザー roarisroaris
提出日時 2019-08-25 21:54:15
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 719 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 852,064 KB
最終ジャッジ日時 2024-04-24 17:03:18
合計ジャッジ時間 5,603 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,632 KB
testcase_01 AC 43 ms
53,760 KB
testcase_02 AC 43 ms
53,504 KB
testcase_03 AC 44 ms
53,248 KB
testcase_04 AC 43 ms
53,760 KB
testcase_05 AC 45 ms
53,504 KB
testcase_06 AC 46 ms
53,632 KB
testcase_07 AC 44 ms
53,632 KB
testcase_08 AC 89 ms
77,568 KB
testcase_09 AC 45 ms
54,144 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0