-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path138.cpp
72 lines (64 loc) · 1.04 KB
/
138.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<bits/stdc++.h>
using namespace std;
int comp(int const &i, int const &j) {
return i > j;
}
void nhap(int a[100][100],int m,int n){
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
}
void tao(int a[100][100],int m,int n){
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
a[i][j]=0;
}
}
}
void in(int a[100][100],int m,int n){
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
}
void xuly(int a[100][100],int m,int n){
int b[100][100];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
b[i][j]=a[i][j];
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(a[i][j]==1&&a[i+1][j]==1) b[i+1][j]=b[i][j]+1;
}
}
for(int i=0;i<m;i++){
sort(b[i],b[i]+n,comp);
}
int x,y=0;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
x=(j+1)*b[i][j];
if (x>y) y=x;
}
}
cout<<y<<endl;
}
int a[100][100];
int main(){
int t;
cin>>t;
while(t--){
int m,n;
cin>>m>>n;
nhap(a,m,n);
xuly(a,m,n);
}
return 0;
}