usaco Home on the Range
2011-10-11 12:36
330 查看
这是一道简单的DP问题。
代码好下:
代码好下:
/* ID: guo geer PROG: range LANG: C++ */ #include<iostream> #include<fstream> #include<cstring> #include<cmath> using namespace std; char data[300][300]; int dp[300][300]; int res[300]; int main() { ifstream fin("range.in"); ofstream fout("range.out"); int n; while(fin>>n) { cin.ignore(); for(int i=0; i<n; i++) fin>>data[i]; for(int i=0; i<n; i++) for(int j=0; j<n; j++) dp[i][j] = data[i][j] - '0'; for(int i=1; i<n; i++) for(int j=1; j<n; j++) if(dp[i][j] == 1) { dp[i][j] = min(dp[i-1][j-1], min(dp[i][j-1], dp[i-1][j]))+1; } memset(res, 0, sizeof(res)); for(int i=1; i<n; i++) for(int j=1; j<n; j++) res[dp[i][j]] ++; for(int i=n-1; i>=2; i--) res[i] += res[i+1]; for(int i=2; i<=n; i++) if(res[i] > 0) fout<<i<<' '<<res[i]<<endl; } return 0; }
相关文章推荐
- USACO Home on the Range
- USACO3.3.4 Home on the Range (range)
- Home On The Range_usaco3.3_dp
- usaco Home on the Range(dp+容斥原理)
- [USACO3.3]家的范围 Home on the Range
- USACO Section 3.3 Home on the Range(dp)
- USACO home on the range C 语言实现
- USACO 3.3 Home on the Range
- USACO-Section 3.3- PROB Home on the Range
- USACO-Section3.3 Home on the Range【完全背包】
- usaco Home on the Range
- usaco Home on the Range java ---DP
- [USACO3.3.4]Home on the Range
- Home on the Range USACO 3.3 (dp阵亡)
- USACO 3.3 Home on the Range (range)
- USACO / Home on the Range (DP统计正方形个数)
- USACO-Section 3.3 Home on the Range (树状数组||DP)
- USACO3.3.4--Home on the Range
- USACO Home on the Range 解题报告
- USACO3.3.4 Home on the Range (range)