結果

問題 No.30 たこやき工場
ユーザー qibqib
提出日時 2023-03-13 03:07:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 70,808 KB
最終ジャッジ日時 2023-10-18 10:51:43
合計ジャッジ時間 2,458 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,404 KB
testcase_01 AC 43 ms
55,404 KB
testcase_02 AC 42 ms
55,404 KB
testcase_03 AC 41 ms
55,404 KB
testcase_04 AC 42 ms
55,404 KB
testcase_05 AC 43 ms
55,404 KB
testcase_06 AC 42 ms
55,404 KB
testcase_07 AC 41 ms
55,404 KB
testcase_08 AC 44 ms
55,404 KB
testcase_09 AC 43 ms
55,404 KB
testcase_10 AC 73 ms
70,808 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

src = n - 1
ans = [0 for _ in range(n)]
ans[src] = 1
used = [False for _ in range(n)]
used[src] = True
dq = deque()
dq.append(src)
while len(dq) > 0:
  cur = dq.popleft()
  for nxt, cost in g[cur]:
    if used[nxt]:
      continue
    ans[nxt] += ans[cur] * cost
    deg[nxt] -= 1
    if deg[nxt] == 0:
      used[nxt] = True
      dq.append(nxt)
  if len(g[cur]) > 0:
    ans[cur] = 0

ans.pop()
print(*ans, sep="\n")
0