結果
| 問題 | No.309 シャイな人たち (1) |
| コンテスト | |
| ユーザー |
tjake
|
| 提出日時 | 2015-12-02 14:59:02 |
| 言語 | Python2 (2.7.18) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,577 bytes |
| コンパイル時間 | 154 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 07:52:42 |
| 合計ジャッジ時間 | 1,010 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 9 |
ソースコード
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
tjake