結果

問題 No.30 たこやき工場
ユーザー zimphazimpha
提出日時 2017-12-12 00:34:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 76,804 KB
最終ジャッジ日時 2023-08-20 17:38:56
合計ジャッジ時間 3,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,572 KB
testcase_01 AC 76 ms
71,396 KB
testcase_02 AC 78 ms
71,408 KB
testcase_03 AC 76 ms
71,460 KB
testcase_04 AC 75 ms
71,504 KB
testcase_05 AC 75 ms
71,544 KB
testcase_06 AC 77 ms
71,096 KB
testcase_07 AC 77 ms
71,568 KB
testcase_08 AC 79 ms
71,444 KB
testcase_09 AC 81 ms
71,276 KB
testcase_10 AC 108 ms
76,804 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
m = int(input())
edges = [[] for i in range(n)]
in_d = [0] * n
out_d = [0] * n
for i in range(m):
  p, r, q = list(map(int, input().split()))
  p -= 1
  q -= 1
  in_d[p] += 1
  out_d[q] += 1
  edges[q].append((p, r))
dp = [0] * n
queue = [n - 1]
dp[-1] = 1
while len(queue):
  u = queue.pop(0)
  for v, r in edges[u]:
    in_d[v] -= 1
    dp[v] += dp[u] * r
    if in_d[v] == 0:
      queue.append(v)
for i, c in enumerate(out_d):
  if c: dp[i] = 0
for x in dp[:n-1]:
  print(x)
0