結果

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

テストケース

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

ソースコード

diff #

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

dpl = [[0]*(c+1) for i in xrange(r+1)]
dpr = [[0]*(c+1) for i in xrange(r+1)]
dps = [[0]*(c+1) for i in xrange(r+1)]

ans = 0

def f(a, b, c):
    r  = ps[j] if a else 1.-ps[j]
    r *= rl[j-1] if b else 1.-rl[j-1]
    r *= rr[j+1] if c else 1.-rr[j+1]
    return r

for i in xrange(r):
    ps = dps[i-1]
    rl = dpl[i]
    rr = dpr[i]
    rs = dps[i]
    si = s[i]
    pi = p[i]
    # left
    for j in xrange(c):
        if si[j]==0:
            rl[j] = pi[j]/100.0
        elif si[j]==1:
            rl[j] = pi[j]*(1. - (1.-rl[j-1])*(1.-ps[j]))/100.0
        elif si[j]==2:
            rl[j] = pi[j]*rl[j-1]*ps[j]/100.0
        else:
            # 3 or 4
            rl[j] = 0
    # right
    for j in xrange(c-1,-1,-1):
        if si[j]==0:
            rr[j] = pi[j]/100.0
        elif si[j]==1:
            rr[j] = pi[j]*(1. - (1.-rr[j+1])*(1.-ps[j]))/100.0
        elif si[j]==2:
            rr[j] = pi[j]*rr[j+1]*ps[j]/100.0
        else:
            # 3 or 4
            rr[j] = 0
    # sum
    for j in xrange(c):
        if si[j]==0:
            rs[j] = pi[j]/100.0
        elif si[j]==1:
            rs[j] = pi[j]*(1.-f(0,0,0))/100.0
        elif si[j]==2:
            rs[j] = pi[j]*(f(1,1,1)+f(1,1,0)+f(1,0,1)+f(0,1,1))/100.0
        elif si[j]==3:
            rs[j] = pi[j]*f(1,1,1)/100.0
        else:
            # 4
            rs[j] = 0
        ans += rs[j]
print ans
0