結果
| 問題 | No.309 シャイな人たち (1) |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-06-29 06:23:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,656 bytes |
| 記録 | |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 96,028 KB |
| 最終ジャッジ日時 | 2026-06-29 06:24:06 |
| 合計ジャッジ時間 | 10,999 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 12 |
ソースコード
import sys
input = sys.stdin.readline
R,C=list(map(int,input().split()))
input()
P=[list(map(int,input().split())) for i in range(R)]
input()
S=[list(map(int,input().split())) for i in range(R)]
DP=[0]*(1<<C)
DP[0]=1
ANS=0
for i in range(R):
NDP=[0]*(1<<C)
for j in range(1<<C):
prob=1
P1=[0]*C
for k in range(C):
if j & (1<<k) != 0:
prob=prob*P[i][k]/100
P1[k]=4-S[i][k]
else:
prob=prob*(100-P[i][k])/100
#print(prob)
if prob==0:
continue
for k in range(1<<C):
prob2=DP[k]
if prob2==0:
continue
#print("!",k,prob2)
P2=P1[:]
Q=[]
UP=[0]*C
for kk in range(C):
if k & (1<<kk) != 0:
P2[kk]+=1
if P2[kk]>=4:
UP[kk]=1
Q.append(kk)
while Q:
x=Q.pop()
for z in [x-1,x+1]:
if 0<=z<C and UP[z]==0:
P2[z]+=1
if P2[z]==4:
UP[z]=1
Q.append(z)
bi=0
count=0
for jj in range(C):
if UP[jj]==1:
bi+=(1<<jj)
count+=1
NDP[bi]+=prob*prob2
ANS+=count*prob*prob2
#print(UP,NDP)
DP=NDP
#print(DP,ANS)
print(ANS)
titia