#include #include #include #include #include #include #include #include #include #include using namespace std; void propagate(vector& y, int& used, int pos){ if(pos<0 || pos>=y.size()) return; if((used>>pos)&1) return; y[pos]++; if(y[pos]>=4){ used |= 1<& y, int& used, int pos){ if(pos<0 || pos>=y.size()) return; if((used>>pos)&1) return; if(y[pos]>=4){ used |= 1< ostream& operator << (ostream& os, vector vec){ for(int i=0; i int main(){ int r,c; cin >> r >> c; vector> p(r, vector(c)); for(int i=0; i> p[i][j]; } } vector> s(r, vector(c)); for(int i=0; i> s[i][j]; } } vector Prob(1< dp(1< dp_(1< next_Prob(1< y(c, 0); for(int j=0; j>j)&1)?p[i][j]:100-p[i][j])/100.0; if((w>>j)&1){ y[j] = 4-s[i][j]; } } if(tmp_p < 1e-12) continue; for(int v=0; v<(1<>j)&1; } for(int j=0; j=4 && ((used>>j)&1)!=1){ used |= 1<=0) z[j-1]++; if(j+1< c) z[j+1]++; } } for(int j=c-1; j>=0; j--){ if(z[j]>=4 && ((used>>j)&1)!=1){ used |= 1<=0) z[j-1]++; if(j+1< c) z[j+1]++; } } int next = 0; int cnt = 0; for(int j=0; j=4)<=4); } dp_[next] += (dp[v] + cnt * Prob[v]) * tmp_p; next_Prob[next] += Prob[v] * tmp_p; } } swap(dp, dp_); swap(Prob, next_Prob); } double ans = 0; for(int i=0; i<(1<