結果
| 問題 | No.30 たこやき工場 | 
| コンテスト | |
| ユーザー |  ytft | 
| 提出日時 | 2022-11-04 02:48:24 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 60 ms / 5,000 ms | 
| コード長 | 548 bytes | 
| コンパイル時間 | 240 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 63,616 KB | 
| 最終ジャッジ日時 | 2024-07-18 07:20:37 | 
| 合計ジャッジ時間 | 1,777 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 | 
ソースコード
import sys input=lambda:sys.stdin.readline().rstrip() N,M=[int(input()) for i in range(2)] prev=[[] for i in range(N)] nex=[0 for i in range(N)] quant=[int(i==N-1) for i in range(N)] for i in range(M): P,Q,R=map(int,input().split()) prev[R-1].append([P-1,Q]) nex[P-1]+=1 check=[] for i in range(N): if nex[i]==0: check.append(i) while check: temp=check.pop() if len(prev[temp]): for i in prev[temp]: quant[i[0]]+=quant[temp]*i[1] nex[i[0]]-=1 if nex[i[0]]==0: check.append(i[0]) quant[temp]=0 for i in quant[:-1]: print(i)
