hdu 2830(Matrix Swapping II)

hdu 2830(Matrix Swapping II)
 1 #include <iostream>
 2 #include < string.h>
 3  using  namespace std;
 4  #define MaxSize 1002
 5  int h[MaxSize],hash[MaxSize];
 6  int n,m;
 7  int main(){
 8      // freopen("in.txt","r",stdin);
 9       while (~scanf("%d%d",&n,&m)){
10          int i,j,ans=0;
11          char ch;
12         memset(h,0, sizeof(h));
13          for(i=0;i<n;i++){
14             getchar();
15             memset(hash,0, sizeof(hash));
16              for(j=0;j<m;j++){
17                 ch=getchar();
18                  // scanf("%c",&ch);
19                   if(ch=='1')    h[j]++;
20                  else    h[j]=0;
21                 hash[h[j]]++;
22             }
23              int temp=0;
24              for(j=MaxSize-2;j>0;j--){
25                 hash[j]+=hash[j+1]; // 每次累积比当前高度大的高度出现次数
26                  temp=hash[j]*j;
27                 ans=ans>temp?ans:temp;
28             }
29         }
30         printf("%d\n",ans);
31     }
32      return 0;
33  }
34 

你可能感兴趣的:(hdu 2830(Matrix Swapping II))