-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path140.cpp
95 lines (85 loc) · 1.43 KB
/
140.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#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];
}
}
}
int max2(int a[],int n){
int m=a[0];
for(int i=1;i<n;i++)
if(m<a[i]) m=a[i];
int maxhai;
for(int j=0;j<n;j++){
if(a[j]!=m){
maxhai=a[j];
break;
}
}
for(int k=0;k<n;k++){
if(a[k]!=m&&a[k]>maxhai) maxhai=a[k];
}
return maxhai;
}
int max(int a[],int n){
int m=a[0];
for(int i=1;i<n;i++)
if(m<a[i]) m=a[i];
return m;
}
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;
}
}
int soLuongDong[m];
for(int i=0;i<m;i++) soLuongDong[i]=0;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(b[i][j]!=0) soLuongDong[i]++;
}
}
int maxS[m];
for(int i=0;i<m;i++){
if(max2(b[i],n)==0) maxS[i]=max(b[i],n);
else maxS[i]=max2(b[i],n);
}
int ans=0;
for(int i=0;i<m;i++){
if(maxS[i]*soLuongDong[i]>ans) ans=maxS[i]*soLuongDong[i];
}
cout<<ans<<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;
}