結果

問題 No.298 話の伝達
ユーザー convexineqconvexineq
提出日時 2021-01-02 15:18:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 96,640 KB
最終ジャッジ日時 2024-04-20 08:46:23
合計ジャッジ時間 3,249 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,888 KB
testcase_01 AC 45 ms
53,504 KB
testcase_02 AC 43 ms
54,016 KB
testcase_03 AC 43 ms
53,504 KB
testcase_04 AC 43 ms
53,888 KB
testcase_05 AC 236 ms
96,640 KB
testcase_06 AC 51 ms
62,848 KB
testcase_07 AC 42 ms
54,272 KB
testcase_08 AC 42 ms
53,888 KB
testcase_09 AC 49 ms
63,140 KB
testcase_10 AC 56 ms
70,784 KB
testcase_11 AC 231 ms
96,640 KB
testcase_12 AC 144 ms
86,144 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 43 ms
54,272 KB
testcase_16 AC 230 ms
96,640 KB
testcase_17 AC 55 ms
66,432 KB
testcase_18 AC 103 ms
81,196 KB
testcase_19 AC 42 ms
53,504 KB
testcase_20 AC 143 ms
86,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
prob = [[0.0]*n for _ in range(n)]
g = [[] for _ in range(n)]
indegree = [0]*n
for _ in range(m):
    a,b,c = map(int,input().split())
    prob[a][b] = c/100
    g[a].append(b)
    indegree[b] += 1
from collections import deque
q = deque(i for i in range(n) if indegree[i]==0)
order = []
while q:
    i = q.popleft()
    order.append(i)
    for b in g[i]:
        indegree[b] -= 1
        if indegree[b]==0: q.append(b)
dp = [0.0,1.0]
for i in range(1,n):
    p = order[i]
    N = 1<<i
    ndp = [0.0]*(2*N)
    for mask in range(N):
        x = 1.0
        for j in range(i):
            x *= 1.0-(mask>>j&1)*prob[order[j]][p]
        ndp[mask] += dp[mask]*x
        ndp[mask+N] += dp[mask]*(1-x)
    dp = ndp
print(sum(dp[N:]))
0