#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include #include //#include #include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; typedef double Real; const int MAX = 11; int P[MAX][MAX], S[MAX][MAX]; int memo[1<<(2*MAX)]; Real pmemo[MAX][1<> R >> C; for (int i = 0; i < R; i++) for (int j = 0; j < C; j++) cin >> P[i][j]; for (int i = 0; i < R; i++) for (int j = 0; j < C; j++) cin >> S[i][j]; for (int s = 0; s < 1<<(2*C); s++) { vector rest(C); int tmp = s; for (int i = 0; i < C; i++) { rest[i] = tmp%4; tmp /= 4; } queue que; for (int i = 0; i < C; i++) { if (rest[i] == 0) que.push(i); } while (!que.empty()) { int now = que.front(); que.pop(); if (now-1 >= 0) { rest[now-1]--; if (rest[now-1] == 0) que.push(now-1); } if (now+1 < C) { rest[now+1]--; if (rest[now+1] == 0) que.push(now+1); } } int& result = memo[s]; for (int i = 0; i < C; i++) result |= (rest[i]<=0)<>c)&1) prob *= P[r][c]/100.; else prob *= (100-P[r][c])/100.; } } dp[0][0] = 1; for (int r = 0; r < R; r++) { for (int s0 = 0; s0 < (1<= 0; c--) { int score = 0; if ((s1>>c)&1) { score = min(3, S[r][c]-((s0>>c)&1)); score = max(0, score); } else { score = 3; } mask = mask*4+score; } dp[r+1][memo[mask]] += prob; } } } Real ans = 0; for (int i = 1; i <= R; i++) for (int s = 1; s < (1<