結果
問題 | No.298 話の伝達 |
ユーザー | rpy3cpp |
提出日時 | 2015-11-07 02:37:25 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 845 bytes |
コンパイル時間 | 222 ms |
コンパイル使用メモリ | 10,796 KB |
実行使用メモリ | 12,536 KB |
最終ジャッジ日時 | 2023-10-11 14:54:51 |
合計ジャッジ時間 | 10,591 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
7,736 KB |
testcase_01 | AC | 16 ms
7,764 KB |
testcase_02 | AC | 17 ms
7,932 KB |
testcase_03 | AC | 16 ms
7,780 KB |
testcase_04 | AC | 16 ms
7,912 KB |
testcase_05 | AC | 2,700 ms
7,812 KB |
testcase_06 | AC | 18 ms
7,784 KB |
testcase_07 | AC | 16 ms
7,780 KB |
testcase_08 | AC | 15 ms
7,784 KB |
testcase_09 | AC | 19 ms
7,812 KB |
testcase_10 | AC | 24 ms
7,780 KB |
testcase_11 | AC | 177 ms
7,796 KB |
testcase_12 | AC | 93 ms
7,736 KB |
testcase_13 | AC | 193 ms
7,800 KB |
testcase_14 | AC | 133 ms
7,820 KB |
testcase_15 | AC | 16 ms
7,764 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
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): vs = [v for v in range(1, N)] vs.sort(key=lambda v: len(Cs[v])) prob = 0 for on_off in range(1 + (1 << (N - 1)), 1 << N, 2): prob += calc_prob(on_off, vs, Cs) return prob def calc_prob(on_off, vs, Cs): prob = 1 for v in vs: if prob == 0: return 0 p_off = 1 for u, c in Cs[v].items(): if not on_off & (1 << u): continue p_off *= (1 - c) if on_off & (1 << v): prob *= (1 - p_off) else: prob *= p_off return prob N, M, Cs = read_data() print(solve(N, M, Cs))