結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-02-19 21:51:30 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 5,000 ms |
| コード長 | 558 bytes |
| 記録 | |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 77,348 KB |
| 最終ジャッジ日時 | 2025-12-03 14:03:28 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
N=int(raw_input())
outdeg= [0 for i in range(N+1)]
edges=[[] for i in range(N+1)]
cnt = [0 for i in range(N+1)]
M=int(raw_input())
for i in range(M):
P,Q,R = map(int,raw_input().split())
edges[R].append((P,Q))
outdeg[P]+=1
cnt[N]=1
l=[]
for i in range(1,N+1):
if outdeg[i] == 0:
l.append(i)
while len(l)!=0:
cur = l.pop()
if len(edges[cur])!=0 :
for p,q in edges[cur]:
outdeg[p]-=1
cnt[p]+=cnt[cur]*q
if outdeg[p]==0 :
l.append(p)
cnt[cur]=0
for i in range(1,N):
print cnt[i]
yaoshimax