-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhinh_vuong_lon_nhat.cpp
More file actions
46 lines (46 loc) · 961 Bytes
/
hinh_vuong_lon_nhat.cpp
File metadata and controls
46 lines (46 loc) · 961 Bytes
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
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<stack>
#include<string>
using namespace std;
long long mod = 1e9 + 7;
void slove(){
int n,m;
cin >> n >> m;
int a[n][m];
int s[n][m];
int maxs;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++) cin >> a[i][j];
}
for(int i=0;i<n;i++) s[i][0]=a[i][0];
for(int i=0;i<m;i++) s[0][i]=a[0][i];
for(int i=1;i<n;i++){
for(int j=1;j<m;j++){
if(a[i][j]==1){
s[i][j]=min({s[i][j-1],s[i-1][j],s[i-1][j-1]})+1;
}
else s[i][j]=0;
}
}
maxs=s[0][0];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(maxs<s[i][j]) maxs=s[i][j];
}
}
cout << maxs << "\n";
}
int main(){
int t=1;
cin >> t;
while(t--){
slove();
}
return 0;
}