HDU2859】的更多相关文章

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2859 题意:输入一个数n,接下来是一个由n*n个字母组成的矩阵,求以左下到右上的线为轴的最大对称阵的大小. 思路:就是dp,,,我最大的感悟就是dp要是想明白了,代码贼简单,想不懂就是死难..思路么,看下面的图就懂了. 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<…
dp[i][j]代表以s[i][j]字符为右上角的最大对称方阵的尺寸 最左边那一列都为1,然后按列更新,代码实现比较简单,感觉有点卡时间,如果对称度很好,时间应该比较高,我只会这种了 #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include<cstring> #include<cstring…
Today is army day, but the servicemen are busy with the phalanx for the celebration of the 60th anniversary of the PRC. A phalanx is a matrix of size n*n, each element is a character (a~z or A~Z), standing for the military branch of the servicemen on…
Phalanx Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1542    Accepted Submission(s): 757 Problem Description Today is army day, but the servicemen are busy with the phalanx for the celebrati…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859 AC思路:(思路来源于kuangbin,甚至做法也跟kuangbin大同小异,所以可以将本文看成是对于这篇博文(http://www.cnblogs.com/kuangbin/p/3228215.html)的一个评论...) 用dp[i][j]代表以点(i,j)为左下角的最大的对称矩阵的边长,计算从该点出发向上和向右走,字符相等的最大长度x,如果长度x大于dp[i-1][j+1],则dp[i]…
layout: post title: 「kuangbin带你飞」专题十二 基础DP author: "luowentaoaa" catalog: true tags: mathjax: true - kuangbin - 动态规划 传送门 A.HDU1024 Max Sum Plus Plus 题意 给你N个数,然后你分成M个不重叠部分,并且这M个不重叠部分的和最大. 思路 动态规划最大m字段和,dp数组,dp[i][j]表示以a[j]结尾的,i个字段的最大和 两种情况:1.第a[j…
Phalanx 先搬翻译 Descriptions: 给你一个矩阵,只由小写或大写字母构成.求出它的最大对称子矩阵的边长. 其中对称矩阵是一个k*k的矩阵,它的元素关于从左下角到右上角的对角线对称.例如下面这个3* 3的矩阵是对称矩阵:cbxcpbzcc Input 多组数据.每一组第一行是一个 n (0<n<=1000),下面是n行,每一行有n个字母,中间没有空格.数据以n=0结束. Output 每组数据输出最大的对称矩阵的边长. Sample Input 3 abx cyb zca 4…