USACO 3.3 Home on the Range(最大子矩阵问题)
2012-12-02 18:49
387 查看
以前做过类似的。
/* ID: cuizhe LANG: C++ TASK: range */ #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; #define N 501 char str ; int key ,x ,y ; int o ,map ; int Min(int a,int b,int c) { int t = a; if(t > b) t = b; if(t > c) t = c; return t; } int main() { int i,j,k,n; freopen("range.in","r",stdin); freopen("range.out","w",stdout); scanf("%d",&n); for(i = 1;i <= n;i ++) scanf("%s",str[i]); for(i = 1;i <= n;i ++) { for(j = 1;j <= n;j ++) { if(str[i][j-1] == '1') map[i][j] = 1; } } for(i = 1;i <= n;i ++) { for(j = 1;j <= n;j ++) { if(map[i][j] == 1) { x[i][j] = x[i-1][j]+1; y[i][j] = y[i][j-1]+1; if(map[i-1][j-1] == 1) key[i][j] = Min(x[i][j],y[i][j],key[i-1][j-1]+1); else key[i][j] = 1; } else { x[i][j] = 0; y[i][j] = 0; key[i][j] = 0; } } } for(i = 1;i <= n;i ++) { for(j = 1;j <= n;j ++) { for(k = 2;k <= key[i][j];k ++) { o[k] ++; } } } for(i = 2;i <= n;i ++) { if(o[i]) printf("%d %d\n",i,o[i]); } return 0; }
相关文章推荐
- Home On The Range_usaco3.3_dp
- USACO Section 3.3 Home on the Range - 优化的BFS..
- [USACO3.3]家的范围 Home on the Range
- USACO--3.3Home on the Range+DP
- USACO 3.3 Home on the Range (range)
- USACO Section 3.3 Home on the Range
- USACO 3.3 Home on the Range
- usaco 3.3 Home on the Range
- USACO-Section 3.3- PROB Home on the Range
- Home on the Range USACO 3.3 (dp阵亡)
- USACO-Section3.3 Home on the Range【完全背包】
- USACO-Section 3.3 Home on the Range (树状数组||DP)
- USACO Section 3.3 Home on the Range(dp)
- USACO Home on the Range
- USACO Home on the Range
- USACO section3.3 Home on the Range(压缩+枚举)
- [USACO]Home on the Range
- USACO home on the range C 语言实现
- USACO section3.3 Home on the Range(压缩+枚举)
- usaco Home on the Range