結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-11-16 08:10:22 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 5,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-12-15 23:05:48 |
| 合計ジャッジ時間 | 1,382 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
N=int(input())
M=int(input())
E=[[] for i in range(N+1)]
OUT=[0]*(N+1)
for i in range(M):
p,q,r=map(int,input().split())
E[r].append((p,q))
OUT[p]+=1
Q=[]
for i in range(N+1):
if OUT[i]==0:
Q.append(i)
ANS=[0]*(N+1)
ANS[-1]=1
while Q:
x=Q.pop()
for to,q in E[x]:
OUT[to]-=1
if OUT[to]==0:
Q.append(to)
ANS[to]+=ANS[x]*q
if E[x]!=[]:
ANS[x]=0
print("\n".join(map(str,ANS[1:-1])))
titia