結果

問題 No.30 たこやき工場
ユーザー lloyzlloyz
提出日時 2023-08-27 14:32:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-08-27 14:32:28
合計ジャッジ時間 1,645 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,512 KB
testcase_01 AC 19 ms
8,632 KB
testcase_02 AC 18 ms
8,584 KB
testcase_03 AC 18 ms
8,668 KB
testcase_04 AC 19 ms
8,496 KB
testcase_05 AC 19 ms
8,564 KB
testcase_06 AC 19 ms
8,524 KB
testcase_07 AC 18 ms
8,524 KB
testcase_08 AC 19 ms
8,520 KB
testcase_09 AC 20 ms
8,584 KB
testcase_10 AC 23 ms
8,696 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque

n = int(input())
m = int(input())
G = defaultdict(list)
INcnt = [0 for _ in range(n)]
for _ in range(m):
    p, q, r = map(int, input().split())
    G[r - 1].append((p - 1, q))
    INcnt[p - 1] += 1

ANS = [0 for _ in range(n - 1)]
C = [0 for _ in range(n)]
C[n - 1] = 1
Que = deque([n - 1])
while Que:
    cp = Que.popleft()
    cnt = C[cp]
    if len(G[cp]) == 0:
        ANS[cp] = cnt
        continue
    for np, q in G[cp]:
        C[np] += cnt * q
        INcnt[np] -= 1
        if INcnt[np] == 0:
            Que.append(np)
print(*ANS, sep='\n')
0