結果

問題 No.30 たこやき工場
ユーザー dangodango
提出日時 2023-07-09 15:49:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 944 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 305,596 KB
最終ジャッジ日時 2023-09-30 19:09:41
合計ジャッジ時間 4,372 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,316 KB
testcase_01 AC 101 ms
71,320 KB
testcase_02 AC 100 ms
71,628 KB
testcase_03 AC 102 ms
71,708 KB
testcase_04 AC 103 ms
71,636 KB
testcase_05 AC 102 ms
71,460 KB
testcase_06 AC 100 ms
71,760 KB
testcase_07 AC 101 ms
71,668 KB
testcase_08 AC 121 ms
77,400 KB
testcase_09 AC 105 ms
72,268 KB
testcase_10 AC 944 ms
305,596 KB
testcase_11 AC 126 ms
71,660 KB
testcase_12 AC 100 ms
71,540 KB
testcase_13 AC 102 ms
71,780 KB
testcase_14 AC 104 ms
72,368 KB
testcase_15 AC 105 ms
72,176 KB
testcase_16 AC 106 ms
72,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
M = int(input())
cnt = [0] * 101
flag = [False] * 101
Items = [(i, [], []) for i in range(N + 1)]
hyou = [[0] * 101 for _ in range(101)]
cnt[N] = 1
for n in range(M):
    P, Q, R = map(int, input().split())
    flag[R] = True
    Items[P][1].append(R)
    Items[R][2].append(P)
    hyou[P][R] = Q
q = deque()
q.append(N)
while len(q) > 0:
    j = q.popleft()
    p = Items[j]
    if cnt[p[0]] == 0 or flag[p[0]] == False:
        continue
    for k in p[2]:
        cnt[k] += hyou[k][p[0]] * cnt[p[0]]
        q.append(k)
    cnt[p[0]] = 0
for i in range(1, N):
    print(cnt[i])
0