結果

問題 No.30 たこやき工場
ユーザー roarisroaris
提出日時 2019-08-25 21:56:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 719 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 210,176 KB
最終ジャッジ日時 2024-04-24 17:06:43
合計ジャッジ時間 7,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 24 ms
10,624 KB
testcase_02 AC 24 ms
10,752 KB
testcase_03 AC 26 ms
10,624 KB
testcase_04 AC 27 ms
10,624 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 170 ms
11,392 KB
testcase_09 AC 27 ms
10,624 KB
testcase_10 TLE -
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