結果

問題 No.298 話の伝達
ユーザー rpy3cpprpy3cpp
提出日時 2015-11-07 00:49:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-10-11 14:46:50
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,720 KB
testcase_02 AC 16 ms
7,976 KB
testcase_03 AC 15 ms
7,796 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,844 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,964 KB
testcase_08 AC 15 ms
7,796 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 17 ms
7,724 KB
testcase_12 AC 16 ms
7,800 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 16 ms
7,976 KB
testcase_16 AC 16 ms
7,804 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, M = map(int, input().split())
    Cs = [dict() for i in range(N)]
    for m in range(M):
        src, dst, c = map(int, input().split())
        Cs[dst][src] = c/100
    return N, M, Cs

def solve(N, M, Cs):
    global ps, cs
    cs = Cs
    ps = [-1] * N
    ps[0] = 1
    return dfs(N-1)

def dfs(dst):
    global ps, cs
    if ps[dst] != -1:
        return ps[dst]
    tmp = 1
    for src, c in cs[dst].items():
        tmp *= (1 - dfs(src)*c)
    prob = 1 - tmp
    ps[dst] = prob
    return prob

N, M, Cs = read_data()
print(solve(N, M, Cs))
0