标签:
Tyvj 1189 盖房子
4 4
0 1 1 1
1 1 1 0
0 1 1 0
1 1 0 1
2
1 #include<iostream> 2 #include<cstdio> 3 #include<string> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 int n,m,a[1005][1005],dp[1005][1005],ans; 8 int main(){ 9 cin>>n>>m; 10 for(int i = 1;i <= n;i++){ 11 for(int j = 1;j <= m;j++){ 12 cin>>a[i][j]; 13 } 14 } 15 for(int i = 1;i <= n;i++){ 16 for(int j = 1;j <= m;j++){ 17 if(a[i][j]) dp[i][j] = 1 + min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1])); 18 ans = max(ans,dp[i][j]); 19 } 20 } 21 cout<<ans; 22 return 0; 23 }
标签:
原文地址:http://www.cnblogs.com/hyfer/p/4841783.html