USACO3.3.4 Home on the Range (range)
来源:互联网 发布:徐州网络推广 编辑:程序博客网 时间:2024/06/09 03:52
首先dp,
dp[ i ][ j] 表示以点(i,j)为右下角能取到的最大正方形的边长
点[ i ][ j ]被损坏,dp[i][j]=0, 否则dp[i][j]=min{ dp[ i-1 ][ j ] , dp[ i ][ j - 1] , dp[ i-1 ][ j-1 ] } + 1
扫描dp[ ][ ],记录答案输出即可
/*ID:xsy97051LANG:C++TASK:range */#include <cstdio>#include <algorithm>#include <iostream>using namespace std;bool a[255][255];int dp[255][255],cnt[255];int main(){freopen("range.in","r",stdin);freopen("range.out","w",stdout);int n;cin>>n;for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){char c;cin>>c;if(c=='1') a[i][j]=1;}for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(a[i][j])dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int k=2;k<=dp[i][j];k++) cnt[k]++; for(int i=2;i<=n;i++) if(cnt[i]!=0) cout<<i<<" "<<cnt[i]<<endl; return 0;}
0 0
- USACO3.3.4 Home on the Range (range)
- USACO3.3.4 Home on the Range (range)
- [USACO3.3.4]Home on the Range
- [USACO3.3]家的范围 Home on the Range
- Home on the Range
- USACO 3.3 Home on the Range (range)
- usaco Home on the Range
- USACO Home on the Range
- USACO Home on the Range
- usaco Home on the Range
- Section 3.3 Home on the Range
- usaco Home on the Range java ---DP
- usaco 3.3 Home on the Range
- USACO Home on the Range 解题报告
- USACO Section 3.3 Home on the Range
- USACO--3.3Home on the Range+DP
- usaco Chapter 3 section 3.3 Home on the Range
- USACO Section 3.3 Home on the Range - 优化的BFS..
- 前端进阶学习(三) --css框架初探
- [Leetcode]Permutations
- HTTP消息头中的“Cache-control”控制网页的缓存
- 等级考试(一):三级网络---似曾相识
- centos5.8下php-5.3.2.tar.gz的安装
- USACO3.3.4 Home on the Range (range)
- 工作总结_5
- Intersection of Two Linked Lists
- C++随笔 delete void *
- 黑马程序员——Object C基础——类的声明、创建
- Service Locator Patten 总结
- Android简易网络请求框架
- opencv计算直方图
- acdream 1116 Gao the string!