結果
問題 | No.30 たこやき工場 |
ユーザー | ayaoni |
提出日時 | 2020-12-04 16:46:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 82 ms / 5,000 ms |
コード長 | 1,060 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 87,292 KB |
実行使用メモリ | 76,924 KB |
最終ジャッジ日時 | 2023-08-23 05:23:46 |
合計ジャッジ時間 | 2,453 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,412 KB |
testcase_01 | AC | 70 ms
71,176 KB |
testcase_02 | AC | 70 ms
71,412 KB |
testcase_03 | AC | 69 ms
71,444 KB |
testcase_04 | AC | 70 ms
71,176 KB |
testcase_05 | AC | 75 ms
71,412 KB |
testcase_06 | AC | 70 ms
71,204 KB |
testcase_07 | AC | 70 ms
71,408 KB |
testcase_08 | AC | 71 ms
71,312 KB |
testcase_09 | AC | 71 ms
71,448 KB |
testcase_10 | AC | 82 ms
76,924 KB |
testcase_11 | AC | 71 ms
71,624 KB |
testcase_12 | AC | 69 ms
71,516 KB |
testcase_13 | AC | 69 ms
71,212 KB |
testcase_14 | AC | 71 ms
71,436 KB |
testcase_15 | AC | 72 ms
71,328 KB |
testcase_16 | AC | 71 ms
71,356 KB |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N,M = I(),I() Graph = [[] for _ in range(N+1)] flag = [1]*(N+1) for _ in range(M): P,Q,R = MI() Graph[P].append((R,Q)) flag[R] = 0 def f(i): if ANS[i] != -1: return ANS[i] if i == N: ANS[N] = 1 return 1 res = 0 for j,c in Graph[i]: if ANS[j] != -1: res += ANS[j]*c else: x = f(j) ANS[j] = x res += x*c ANS[i] = res return res ANS = [-1]*(N+1) for i in range(1,N+1): if ANS[i] == -1: f(i) ANS = [ANS[i] if flag[i] == 1 else 0 for i in range(1,N)] print(*ANS,sep='\n')