#include "bits/stdc++.h" #include #pragma warning(disable:4996) using namespace std; using ld = long double; template using Table = vector>; ld pers[11][11]; int shys[11][11]; vector>hands; int main() { int R, C; cin >> R >> C; hands.resize(R+1); for (int i = 0; i < hands.size(); ++i){ hands[i].resize(1 << C); } for (int i = 0; i < R; ++i){ for (int j = 0; j < C; ++j){ cin >> pers[i][j]; pers[i][j] /= 100; } } for (int i = 0; i < R; ++i){ for (int j = 0; j < C; ++j){ cin >> shys[i][j]; } } for (int i = 0; i < (1 << C); ++i){ hands[0][i] = 0; } hands[0][0] = 1; ld ans = 0; for (int r = 1; r <= R; ++r){ for (int k = 0; k < (1 << C); ++k){ for (int l = 0; l < (1 << C); ++l){ bitset<11>prehands(k),knows(l); ld percentage = hands[r - 1][k]; bitset<11>ups(0); for (int i = 0; i < C; ++i){ if (knows[i]){ percentage *= pers[r - 1][i]; } else{ percentage *= 1-pers[r - 1][i]; } } for (int i = 0; i < C; ++i){ int point = knows[i] ? 4 - shys[r-1][i] : 0; if (i != 0){ if (ups[i - 1])point++; } if (prehands[i])point++; if (i != C - 1){ if (ups[i + 1])point++; } if (point >= 4)ups[i] = true; } for (int i = C-1; i >=0; --i){ int point = knows[i] ? 4 - shys[r - 1][i] : 0; if (i != 0){ if (ups[i - 1])point++; } if (prehands[i])point++; if (i != C - 1){ if (ups[i + 1])point++; } if (point >= 4)ups[i] = true; } hands[r][ups.to_ulong()] += percentage; ans += percentage*ups.count(); } } } cout <