結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2020-12-13 02:30:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 660 bytes |
| コンパイル時間 | 323 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 63,616 KB |
| 最終ジャッジ日時 | 2024-09-19 22:41:49 |
| 合計ジャッジ時間 | 1,781 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 11 |
ソースコード
from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
M = int(input())
out = [0] * N
parent = [[] for _ in range(N)]
for _ in range(M):
s, c, t = map(int, input().split())
s -= 1
t -= 1
out[s] += 1
parent[t].append((s, c))
cnt = [0] * N
que = deque()
for i, o in enumerate(out):
if not o:
cnt[i] = 1
que.append(i)
while que:
s = que.popleft()
d = cnt[s]
for t, c in parent[s]:
cnt[t] += c * d
out[t] -= 1
if out[t] == 0:
que.append(t)
if parent[s]:
cnt[s] = 0
print(*cnt[:-1], sep="\n")
tktk_snsn