题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859 给你一个n*n的矩阵,问你最大的对称度是多少(左下右上为对称线) dp[i][j]表示i行j列元素的最大对称度 每到一个元素的时候,往上边和右边扩展看字符最优的对称长度 与dp[i - 1][j - 1]进行比较取最优即可. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm&…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2859 Phalanx Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2792    Accepted Submission(s): 1357 Problem Description Today is army day, but the s…
Phalanx 先搬翻译 Descriptions: 给你一个矩阵,只由小写或大写字母构成.求出它的最大对称子矩阵的边长. 其中对称矩阵是一个k*k的矩阵,它的元素关于从左下角到右上角的对角线对称.例如下面这个3* 3的矩阵是对称矩阵:cbxcpbzcc Input 多组数据.每一组第一行是一个 n (0<n<=1000),下面是n行,每一行有n个字母,中间没有空格.数据以n=0结束. Output 每组数据输出最大的对称矩阵的边长. Sample Input 3 abx cyb zca 4…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859 题目大意:对称矩阵是这样的矩阵,它由“左下到右”线对称. 相应位置的元素应该相同. 例如,这里是3 * 3对称矩阵: cbx cpb zcc 给出任意的n*n的矩阵找出里面最大的对称的子矩阵,输出大小. 解题思路:有这样一个规律,对于每个字符看该列以上和该行右侧的字符匹配量,如果匹配量大于右上角记录下来的矩阵大小,就是右上角的数值+1,否则就是这个匹配量.根据这个规律,把n*n的点都遍历以便一…
Problem Description 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 o…
Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description 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 e…
Phalanx Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 363    Accepted Submission(s): 170 Problem Description Today is army day, but the servicemen are busy with the phalanx for the celebratio…
题意: 如今有一个n*n的矩阵,然后每一个格子中都有一个字母(大写或小写组成).然后询问你如今最大的对称子矩阵的边长是多少.注意这里的对角线是从左下角到右上角上去的. 思路: 这道题我自己写出了dp的定义式,可是要怎么转移方程并没有推出来. 我看了好久的题解才明确的,果然还是太弱... 首先我们定义:dp[i][j]为第i行第j列所可以组成的最大对称子矩阵的长度. 关于对角线全然对称的矩阵! 转移方程为:dp[i][j]=dp[i-1][j+1]+1 : 注意这里是由点(i-1,j+1)推过来的…
感觉是个n^3的dp,只是可能上界比较松吧..转移见代码.值得注意的一个地方是如果n是1,那么在for里面是不会更新答案的,因此ans要初始化为1. 代码如下: #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; + ; char s[N][N]; int dp[N][N]; int n; int main() { && n) { ;i<=…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859 题意就是给你一个n*n的字符矩阵,从中选出一个最大的子矩阵(m*m)满足关于斜对角线(左下角到右上角)对称,求出这个矩阵的大小m: 我们可以用dp[i][j]表示当前位置到右上角这个子矩阵所能表示对称的矩阵最大值: #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm…