博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU2859 Phalanx (动态规划)
阅读量:4582 次
发布时间:2019-06-09

本文共 1655 字,大约阅读时间需要 5 分钟。

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 that position. 
For some special requirement it has to find out the size of the max symmetrical sub-array. And with no doubt, the Central Military Committee gave this task to ALPCs. 
A symmetrical matrix is such a matrix that it is symmetrical by the “left-down to right-up” line. The element on the corresponding place should be the same. For example, here is a 3*3 symmetrical matrix: 
cbx 
cpb 
zcc

InputThere are several test cases in the input file. Each case starts with an integer n (0<n<=1000), followed by n lines which has n character. There won’t be any blank spaces between characters or the end of line. The input file is ended with a 0.OutputEach test case output one line, the size of the maximum symmetrical sub- matrix. 

Sample Input

3abxcybzca4zabacbababbccacq0

Sample Output

33 题意: 问最大对称矩阵,对称轴是这样的:/ 思路: dp[i][j]表示以i,j为左下角坐标的最大矩阵大小。 更新的时候向上和向右走就行了,只是感觉这个复杂度不太正常。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define fuck(x) cout<<#x<<" = "<
<
n){ break;} if(mp[t1][j]==mp[i][t2]){rec++;} else break; } dp[i][j]=1; if(rec>dp[i-1][j+1]){dp[i][j]=dp[i-1][j+1]+1;ans=max(ans,dp[i][j]);} else dp[i][j]=rec; } } printf("%d\n",ans); } return 0;}
View Code

 

 

转载于:https://www.cnblogs.com/ZGQblogs/p/10664506.html

你可能感兴趣的文章
探讨在线支付平台支付接口的设计
查看>>
【设计模式】常用设计模式总结
查看>>
.NET中的六个重要概念
查看>>
二十九、简谈设计模式
查看>>
js中数组的检测方法
查看>>
[译]GotW #6a: Const-Correctness, Part 1
查看>>
JAVA基础学习之 Map集合、集合框架工具类Collections,Arrays、可变参数、List和Set集合框架什么时候使用等(4)...
查看>>
用Python学分析 - 单因素方差分析
查看>>
2018个人年终总结
查看>>
[编辑排版]小技巧---markdown 转 richText
查看>>
JSON_UNESCAPED_UNICODE
查看>>
bug解决思路
查看>>
Oracle没有WM_CONCAT函数的解决办法
查看>>
消息中间件——RabbitMQ(四)命令行与管控台的基本操作!
查看>>
Eclipse 写代码是自动重启服务
查看>>
3.8 spring - AbstractBeanDefinition 介绍
查看>>
如何在Visual Studio里面查看程序的汇编代码?
查看>>
解决IE11只能用管理员身份运行的问题
查看>>
android学习-LocationManager(一)-
查看>>
Linux安装单机solr
查看>>