#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; const int MN = 11; const int r = 11; const int c = 11; int main() { int rr, cc; cin >> rr >> cc; static double p[MN][MN]; static int s[MN][MN]; for (int i = 0; i < rr; i++) { for (int j = 0; j < cc; j++) { cin >> p[i][j]; p[i][j] /= 100.0; } } for (int i = 0; i < rr; i++) { for (int j = 0; j < cc; j++) { cin >> s[i][j]; s[i][j] = 4-s[i][j]; } } double dp1[1<= 4) { ll |= m2; back = true; } else { back = false; } } back = false; for (int m2 = 1<<(c-1), *ss = s[i+1]-1; m2 >= 1; m2>>=1, ss--) { int u = 0; if (l & m2) u = *ss; if (k & m2) u++; if (back) u++; if (ll & (m2>>1)) u++; if (u >= 4 || (ll & m2)) { ll |= m2; back = true; } else { back = false; } } dp2[ll] += dp1[k]*pp; } } for (int j = 0; j < (1<