#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); int used = 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]; } } for(int j=0; j=4 && ((used>>j)&1)==0){ propagate_begin(y,used,j); } } for(int v=0; v<(1<>j)&1; } for(int j=0; j=4 && ((used_>>j)&1)==0){ propagate_begin(z,used_,j); } } int next = 0; int cnt = 0; for(int j=0; j=4)<=4); } dp_[next] += (dp[v] + cnt) * 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<