結果

問題 No.30 たこやき工場
ユーザー takakintakakin
提出日時 2020-06-24 21:53:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 8,780 KB
最終ジャッジ日時 2023-09-16 21:21:26
合計ジャッジ時間 1,600 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
Ans=[0]*n
Ans[-1]=1
Deg=[0]*n
m=int(input())
edge=[[] for _ in range(n)]
for _ in range(m):
  p,q,r=map(int,input().split())
  edge[r-1].append((p-1,q))
  Deg[p-1]+=1
from collections import deque
TS=[v for v in range(n) if Deg[v]==0]
D=deque(TS)
Used=[0]*n
while D:
  v=D.popleft()
  for g,q in edge[v]:
    Deg[g]-=1
    if Deg[g]==0:
      D.append(g)
      TS.append(g)
for i in range(n):
  v=TS[i]
  if edge[v]:
    for g,q in edge[v]:
      Ans[g]=q*Ans[v]
    Ans[v]=0
Ans=Ans[:n-1]
for a in Ans:
  print(a)
0