Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <ext/pb_ds/tree_policy.hpp>
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- typedef int ll;
- typedef unsigned long long ull;
- typedef pair<ll,ll>pll;
- typedef pair<int,int>pii;
- //typedef pair<int,pair<int,int>>piii;
- //typedef pair<ll,pair<ll,ll>>plll;
- //typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> orderedSet;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
- #define sf(a) scanf("%I64d",&a)
- #define pf(a) printf("%I64d\n",a)
- #define mem(a,b) memset(a,b,sizeof(a))
- #define vll(v) v.begin(),v.end()
- #define all(x) x.rbegin(),x.rend()
- #define min3(a, b, c) min(a, min(b, c))
- #define F first
- #define S second
- #define minheap int,vector<int>,greater<int>
- //#define mp make_pair
- #define pb push_back
- #define pp pop_back
- #define eb emplace_back
- #define in freopen("input.txt", "r", stdin)
- #define out freopen("output.txt", "w", stdout)
- #define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
- #define ischar(x) (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
- #define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
- const int Max = 1005;
- const int Mod = 1e9 + 7;
- const double PI =3.141592653589793238463;
- bool compare(const pair<int,int> &a, const pair<int,int> &b)
- {
- return (a.first > b.first);
- }
- ll lcm(ll a,ll b)
- {
- if(a==0 || b==0)return 0;
- return a/__gcd(a,b)*b;
- }
- //___________________________________________________________________________________________________________________
- // CODE STARTS FROM HERE
- // MU_Codefighter2019
- //-------------------------------------------------------------------------------------------------------------------
- ll ara[Max][Max],cum[Max][Max],n,m;
- void input()
- {
- ll i,j;
- for(i=1; i<=n; i++)
- {
- for(j=1; j<=m; j++)
- {
- scanf("%d",&ara[i][j]);
- if(ara[i][j])
- {
- cum[i][j]=cum[i-1][j]+1;
- }
- else
- cum[i][j]=0;
- }
- }
- }
- ll solution()
- {
- ll pos,i,j,len,sq,ans=0;
- for(i=1; i<=n; i++)
- {
- for(j=1; j<=m; j++)
- {
- if(cum[i][j])
- {
- len=1;
- pos=j;
- sq=cum[i][j];
- while(j<=m and sq>=len)
- {
- j++;
- if(cum[i][j]<sq)
- {
- sq=cum[i][j];
- pos=j;
- }
- len++;
- }
- j=pos;
- ans=max(ans,len-1);
- }
- }
- }
- return ans;
- }
- int main()
- {
- fastread();
- ll cas=1,t,i,k;
- while(scanf("%d %d",&n,&m) && (n || m))
- {
- input();
- printf("%d\n",solution());
- }
- }
- // problem : https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2868
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement