usaco Home on the Range
来源:互联网 发布:mac照片如何导入相薄 编辑:程序博客网 时间:2024/05/15 00:13
这是一道简单的DP问题。
代码好下:
/*ID: guo geerPROG: rangeLANG: 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
- USACO Home on the Range
- USACO Home on the Range
- usaco Home on the Range
- USACO 3.3 Home on the Range (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..
- USACO section3.3 Home on the Range(压缩+枚举)
- USACO home on the range C 语言实现
- USACO-Section 3.3-PROB Home on the Range
- Home on the Range
- USACO3.3.4 Home on the Range (range)
- USACO3.3.4 Home on the Range (range)
- Sysstat 软件包集成如下工具:
- DBM、GDBM与C语言跨平台代码研究
- vc6操作PostgreSQL 测试下异步通知接口
- 推荐10款非常优秀的HTML5开发工具
- C#给XmlNode节点添加Name属性
- usaco Home on the Range
- 随笔杂谈之字符串存在性验证
- 新好男人
- tuxedo: 操作手记--常用命令
- Windows rootkits of 2005, part three(翻译)
- python challenge 第二关最简解法 http://www.pythonchallenge.com
- mysql命令导入导出数据库
- City Horizon
- Fedora:Linux下数学工具R