結果

問題 No.66 輝け☆全国たこやき杯
ユーザー maspymaspy
提出日時 2020-03-18 18:30:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 180 ms / 5,000 ms
コード長 504 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 29,844 KB
最終ジャッジ日時 2023-08-20 20:08:45
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
29,680 KB
testcase_01 AC 106 ms
29,708 KB
testcase_02 AC 111 ms
29,624 KB
testcase_03 AC 107 ms
29,824 KB
testcase_04 AC 111 ms
29,644 KB
testcase_05 AC 109 ms
29,796 KB
testcase_06 AC 111 ms
29,800 KB
testcase_07 AC 122 ms
29,628 KB
testcase_08 AC 139 ms
29,832 KB
testcase_09 AC 180 ms
29,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

M = int(readline())
S = np.array(read().split(), np.int64)
S **= 2

dp = np.ones(1 << M)
for i in range(M):
    newdp = np.empty(1 << M)
    n = 1 << i
    for j in range(1 << M):
        k = (1 ^ (j >> i)) << i
        win_per = S[j] / (S[k: k + n] + S[j])
        newdp[j] = dp[j] * (win_per * dp[k:k + n]).sum()
    dp = newdp
print(dp[0])
0