#include #include #include using namespace std ; const int MAXC = 1000 ; char a[MAXC*MAXC] ; int r, c, sum[MAXC], dp[2][MAXC][MAXC], minx[MAXC][MAXC] ; string s ; int main() { cin >> r >> c ; for (int i=0; i> s ; for (int j=0; j= c) a[j+c*i] = s[j] - '0' ; else a[i+r*j] = s[j] - '0' ; } if (r < c) swap(r, c) ; int rd=0, wr=1 ; for (int i=0; i