結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 11 ms
6,020 KB
testcase_02 WA -
testcase_03 AC 11 ms
5,844 KB
testcase_04 AC 12 ms
6,008 KB
testcase_05 AC 11 ms
5,884 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 11 ms
5,824 KB
testcase_14 AC 12 ms
6,008 KB
testcase_15 AC 11 ms
5,924 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.5]*c + [0] for i in xrange(r)] + [[0]*(c+1)]
ans = 0.0
for i in xrange(r):
    si = s[i]
    pi = p[i]
    dpp = dp[i-1]
    dpi = dp[i]
    update = 1
    resd = -1
    while update:
        update = 0
        res = 0.0
        for j in xrange(c):
            if si[j]==0:
                nxt = pi[j]/100.0
            elif si[j]==1:
                nxt = pi[j]*(1.0 - f(0,0,0))/100.0
            elif si[j]==2:
                nxt = pi[j]*(f(1,1,1)+f(1,1,0)+f(1,0,1)+f(0,1,1))/100.0
            elif si[j]==3:
                nxt = pi[j]*f(1,1,1)/100.0
            else:
                nxt = 0.0
            if not nxt-1e-12 < dpi[j] < nxt+1e-12:
                update = 1
            dpi[j] = nxt
        for j in xrange(c):
            res += dpi[j]
        if not resd-1e-12 < res < resd+1e-12:
            update = 1
        resd = res
    ans += resd
print ans
0