結果

問題 No.1364 [Renaming] Road to Cherry from Zelkova
ユーザー gorugo30gorugo30
提出日時 2021-01-22 22:31:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 1,129 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 133,904 KB
最終ジャッジ日時 2023-08-27 20:22:57
合計ジャッジ時間 16,563 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,476 KB
testcase_01 AC 98 ms
71,680 KB
testcase_02 AC 100 ms
71,520 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 184 ms
88,716 KB
testcase_24 AC 194 ms
86,584 KB
testcase_25 AC 287 ms
94,160 KB
testcase_26 AC 382 ms
102,124 KB
testcase_27 AC 346 ms
98,648 KB
testcase_28 AC 236 ms
90,912 KB
testcase_29 AC 340 ms
98,416 KB
testcase_30 AC 246 ms
89,996 KB
testcase_31 AC 203 ms
88,996 KB
testcase_32 AC 288 ms
94,712 KB
testcase_33 AC 409 ms
104,008 KB
testcase_34 AC 360 ms
103,480 KB
testcase_35 AC 363 ms
107,048 KB
testcase_36 AC 354 ms
106,428 KB
testcase_37 AC 274 ms
96,052 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 310 ms
133,904 KB
testcase_44 AC 284 ms
118,244 KB
testcase_45 AC 311 ms
133,904 KB
testcase_46 AC 115 ms
81,324 KB
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
to = [[] for i in range(N + 1)]
for i in range(M):
    u, v, l, a = map(int, input().split())
    to[u].append([v, l, a, len(to[u])])

used = set()
from collections import deque
qu = deque([0])
dp = [[0, 0] for i in range(N + 1)]
dp[0] = [1, 0]
while len(qu):
    v = qu.popleft()
    for nv, l, a, i in to[v]:
        if (v, nv, i) in used:
            print("INF")
            exit()
        dp[nv][0] = (dp[v][0] * a + dp[nv][0]) % MOD
        dp[nv][1] = ((dp[v][1] + l) * a + dp[nv][1]) % MOD
        used.add((v, nv, i))
        qu.append(nv)
print(dp[N][1])
0