Guest User

Untitled

a guest
Dec 24th, 2013
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. //Lasha Bukhnikashvili
  2. #include<iostream>
  3. #include<stdio.h>
  4. #include<math.h>
  5. #include<iomanip>
  6. #include<algorithm>
  7. #include<vector>
  8. #include<map>
  9. #include<queue>
  10. #include<string>
  11. #define Pi 3.14159265358
  12. #define mod9 %1000000009
  13. #define INF 1000000000
  14. #define mod7 %1000000007
  15. #define LL  long long
  16. #define time clock()/(double)CLOCKS_PER_SEC
  17. using namespace std;
  18. char ch;
  19.  int n,m,i,j,ans,a[5001][5001],num[5001][5001],dp[5001][5001];
  20.  void make(int l,int r){
  21.       num[r][l]+=1;
  22.  };
  23. int main(){
  24.  #ifndef ONLINE_JUDGE
  25.    freopen("input.txt","r",stdin);
  26.    freopen("output.txt","w",stdout);
  27.  #endif
  28.     cin>>n>>m;
  29.     for (i=1;i<=n;i++)
  30.     {
  31.         char tmp[5001]; getch(tmp);
  32.     for (int j = 1; j <= m; j++)
  33.         a[i][j] = tmp[j - 1];
  34.     }
  35.     for (i=1;i<=n;i++)
  36.       for (j=1;j<=m;j++){
  37.             if (a[i][j]==1){
  38.                if (a[i][j-1]==0) make(j,j),dp[i][j]=j;
  39.                   else make(dp[i][j-1],j),dp[i][j]=dp[i][j-1];
  40.             };
  41.     };
  42.     for (i=1;i<=m;i++)
  43.         for (j=1;j<=i;j++)
  44.             num[i][j]+=num[i][j-1];
  45.     for (i=1;i<=m;i++)
  46.         for (j=i;j<=m;j++)
  47.             ans=max(ans,(j-i+1)*num[j][i]);
  48.     cout<<ans;
  49.  return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment