結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2015-02-19 21:51:30 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 113 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 05:19:15 |
合計ジャッジ時間 | 1,109 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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]