#ifdef ONPC #define _GLIBCXX_DEBUG #endif #include using namespace std; typedef long long ll; typedef vector vi; typedef vector> vvi; typedef vector> vpi; typedef pair pi; #define F first #define S second #define PB push_back #define MP make_pair #define popcount __builtin_popcountll #define forn(i,a,b) for (int i = a; i < b; i++) void solve(){ int n,m;cin>>n>>m; vvi grid(n,vi(m)); forn(i,0,n){ forn(j,0,m){ cin>>grid[i][j]; } } int x=0; forn(i,0,n-1){ forn(j,0,m-1){ if(grid[i][j]==1&&grid[i][j+1]&&grid[i+1][j+1])x=1; } } if(x==0){ cout<<0; return; } vvi down(n,vi(m)); for(int i=n-1;i>=0;i--){ forn(j,0,m){ if(grid[i][j]==1){ down[i][j]=1; if(i!=n-1){ down[i][j]+=down[i+1][j]; } } } } int ans=0; forn(i,0,n){ forn(j,0,m){ if(grid[i][j]!=1)continue; int curr=1; forn(k,j+1,m){ if(grid[i][k]!=1)break; curr=max(curr,k-j+down[i][k]); } ans=max(ans,curr); } } cout<=0;j--){ // } // } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t=1; // cin >> t; forn(i,0,t){ solve(); } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif }