結果
問題 | No.298 話の伝達 |
ユーザー | rpy3cpp |
提出日時 | 2015-11-07 01:23:41 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 737 bytes |
コンパイル時間 | 438 ms |
コンパイル使用メモリ | 10,904 KB |
実行使用メモリ | 12,680 KB |
最終ジャッジ日時 | 2023-10-11 14:50:19 |
合計ジャッジ時間 | 18,746 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
7,812 KB |
testcase_01 | AC | 15 ms
7,712 KB |
testcase_02 | AC | 15 ms
7,816 KB |
testcase_03 | AC | 16 ms
7,736 KB |
testcase_04 | AC | 16 ms
7,784 KB |
testcase_05 | AC | 2,562 ms
7,816 KB |
testcase_06 | AC | 20 ms
7,868 KB |
testcase_07 | AC | 15 ms
7,928 KB |
testcase_08 | AC | 15 ms
7,924 KB |
testcase_09 | AC | 20 ms
7,816 KB |
testcase_10 | AC | 73 ms
7,872 KB |
testcase_11 | AC | 2,888 ms
7,736 KB |
testcase_12 | AC | 1,292 ms
7,780 KB |
testcase_13 | AC | 3,104 ms
7,724 KB |
testcase_14 | AC | 1,398 ms
7,796 KB |
testcase_15 | AC | 16 ms
7,876 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): prob = 0 for on_off in range(1 + (1 << (N - 1)), 1 << N, 2): prob += calc_prob(on_off, N, Cs) return prob def calc_prob(on_off, N, Cs): prob = 1 for v in range(1, N): 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))