#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; const int MN = 11; int main() { int r, c; cin >> r >> c; static double p[MN][MN]; static int s[MN][MN]; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> p[i][j]; p[i][j] /= 100.0; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> s[i][j]; s[i][j] = 4-s[i][j]; } } static double dp1[1< q; for (int m = 0; m < c; m++) { if (u[m] >= 4) { q.push(m); } } int ll = 0; while (!q.empty()) { int m = q.front(); q.pop(); if (ll & (1< 0) { u[m-1]++; if (u[m-1] == 4) q.push(m-1); } if (m < c-1) { u[m+1]++; if (u[m+1] == 4) q.push(m+1); } } dp2[ll] += dp1[k]*pp; } } for (int j = 0; j < (1<