結果

問題 No.309 シャイな人たち (1)
ユーザー tjaketjake
提出日時 2015-12-02 01:16:32
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 975 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 6,088 KB
最終ジャッジ日時 2023-10-12 08:37:54
合計ジャッジ時間 2,479 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
5,864 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 14 ms
5,968 KB
testcase_15 AC 107 ms
5,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

r, c = map(int, raw_input().split())
raw_input()
p = [map(int, raw_input().split()) + [0] for i in xrange(r)] + [0]*(c+1)
raw_input()
s = [map(int, raw_input().split()) + [4] for i in xrange(r)] + [4]*(c+1)

def f(a, b, c):
    r = 1.0
    r *= dpp[j] if a else 1.0-dpp[j]
    r *= dpi[j-1] if b else 1.0-dpi[j-1]
    r *= dpi[j+1] if c else 1.0-dpi[j+1]
    return r

dp = [[0]*(r+1) for i in xrange(c+1)]
ans = 0.0
for i in xrange(r):
    si = s[i]
    pi = p[i]
    dpp = dp[i-1]
    dpi = dp[i]
    for k in xrange(1000):
        for j in xrange(c):
            if si[j]==0:
                dpi[j] = pi[j]/100.0
            elif si[j]==1:
                dpi[j] = pi[j]*(1.0 - f(0,0,0))/100.0
            elif si[j]==2:
                dpi[j] = pi[j]*(f(1,1,1)+f(1,1,0)+f(1,0,1)+f(1,1,0))/100.0
            elif si[j]==3:
                dpi[j] = pi[j]*f(1,1,1)/100.0
            else:
                dpi[j] = 0.0
    for j in xrange(c):
        ans += dpi[j]
print ans
0