結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-09 15:49:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 877 ms / 5,000 ms |
| コード長 | 627 bytes |
| コンパイル時間 | 623 ms |
| コンパイル使用メモリ | 82,036 KB |
| 実行使用メモリ | 299,408 KB |
| 最終ジャッジ日時 | 2024-07-23 12:54:41 |
| 合計ジャッジ時間 | 2,698 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
from collections import deque
N = int(input())
M = int(input())
cnt = [0] * 101
flag = [False] * 101
Items = [(i, [], []) for i in range(N + 1)]
hyou = [[0] * 101 for _ in range(101)]
cnt[N] = 1
for n in range(M):
P, Q, R = map(int, input().split())
flag[R] = True
Items[P][1].append(R)
Items[R][2].append(P)
hyou[P][R] = Q
q = deque()
q.append(N)
while len(q) > 0:
j = q.popleft()
p = Items[j]
if cnt[p[0]] == 0 or flag[p[0]] == False:
continue
for k in p[2]:
cnt[k] += hyou[k][p[0]] * cnt[p[0]]
q.append(k)
cnt[p[0]] = 0
for i in range(1, N):
print(cnt[i])