結果

問題 No.30 たこやき工場
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-19 21:51:30
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 558 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 6,700 KB
実行使用メモリ 6,096 KB
最終ジャッジ日時 2023-08-23 05:15:01
合計ジャッジ時間 1,613 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,936 KB
testcase_01 AC 12 ms
5,936 KB
testcase_02 AC 12 ms
5,952 KB
testcase_03 AC 11 ms
6,084 KB
testcase_04 AC 11 ms
5,852 KB
testcase_05 AC 11 ms
5,976 KB
testcase_06 AC 11 ms
5,988 KB
testcase_07 AC 11 ms
5,940 KB
testcase_08 AC 12 ms
5,852 KB
testcase_09 AC 12 ms
5,960 KB
testcase_10 AC 16 ms
6,024 KB
testcase_11 AC 12 ms
5,892 KB
testcase_12 AC 11 ms
5,864 KB
testcase_13 AC 11 ms
6,044 KB
testcase_14 AC 12 ms
5,948 KB
testcase_15 AC 12 ms
6,096 KB
testcase_16 AC 12 ms
5,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]
0