HDU 2859 Phalanx(二维DP)
来源:互联网 发布:网络信息安全相关专业 编辑:程序博客网 时间:2024/05/17 01:57
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2859
题意:求最大的对称矩阵
思路:从右上角到左下角进行DP
AC代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <cstring>#include <climits>#include <cmath>#include <cctype>const int inf = 0x3f3f3f3f;//1061109567typedef long long LL;using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1char map1[1010][1010];int dp[1010][1010];int main(){ int n; while(scanf("%d",&n) && n) { memset(dp,0,sizeof(dp)); for(int i=1; i<=n; i++) scanf("%s",map1[i]+1); int ans = 1; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { int x = i,y=j; int temp = 0; while(x>=1 && y<=n && map1[x][j] == map1[i][y]) { temp++; x--; y++; } if(temp >= dp[i-1][j+1]+1) dp[i][j] = dp[i-1][j+1]+1; else dp[i][j] = temp; ans = max(ans,dp[i][j]); } } printf("%d\n",ans); } return 0;}
0 0
- HDU 2859 Phalanx(二维DP)
- HDU 2859 Phalanx(二维dp)
- 【HDU】2859 Phalanx (DP)
- HDU 2859 Phalanx(DP)
- HDU 2859 Phalanx(DP)
- HDU 2859 Phalanx (DP)
- HDU 2859 Phalanx (DP)
- HDU 2859 Phalanx (DP)
- 【DP】 HDU 2859 Phalanx
- hdu-2859 Phalanx 【dp】
- DP-HDU-2859-Phalanx
- hdu(2859)——Phalanx(dp)
- Q - Phalanx HDU 2859 ( dp )
- HDU 2859 Phalanx 简单DP
- 简单dp,HDU 2859 Phalanx
- HDU 2859 Phalanx(dp吧~ ~ ~)
- HDU 2859 Phalanx——DP
- HDOJ 2859 Phalanx (基础DP)
- Android方法记录
- jquery上传文件插件-puupload.js
- SSL协议
- mysql命令大全
- 机器学习相关——协同过滤
- HDU 2859 Phalanx(二维DP)
- 位运算判断奇偶
- redmine邮箱配置
- 手机数据连接接入(外网)访问xampp
- 推荐系统经典论文文献及业界应用
- struct的成员对齐
- OpenCV之Python学习笔记
- 利用Node.js流和事件处理文本文件
- C#反射,特性,数据库结合使用