当前位置:网站首页>Nc1033 palindrome substring of small a (ring, interval DP)
Nc1033 palindrome substring of small a (ring, interval DP)
2022-06-28 22:09:00 【seez】

Because it is a palindrome substring problem , First of all, we should think about how to deal with the palindrome string problem
- Substring : Successive
- Subsequence : Discontinuous
For substring, the method similar to subsequence can be adopted

Boundary treatment is different
initialization : All for false
The border :len==1 Set to true len==2 And s[i]==s[j],dp[i][j]=true
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 5010;
bool dp[2*N][2*N];
int main()
{
string s;
cin >> s;
int n = s.size();
s = s + s;
int res = 0;
for (int len = 1;len <= n;len++)
for (int i = 0;i + len - 1 < 2 * n;i++)
{
int j = i + len - 1;
if (len == 1)
dp[i][j] = true;
else if (len == 2 && s[i] == s[j])
dp[i][j] = true;
else
{
if (s[i] == s[j])
dp[i][j]|=dp[i+1][j-1];
}
if (dp[i][j])
res = max(res, len);
}
cout << res;
}边栏推荐
- 安全 创新 实践|海泰方圆受邀参加“数字时代的网信创新与价值共创”技术交流研讨会
- If you are a C developer, look at these three explicit programming techniques
- External parameter calibration method for 16 line mechanical radar and monocular camera based on solid state lidar
- CORBA Architecture Guide (Common Object Request Broker Architecture)
- docker下载Mysql镜像创建数据库链接时候发生密码错误问题
- LeetCode123. The best time to buy and sell stocks III
- Ctrip will push the "3+2" working mode: 3 days a week on duty and 2 days of free choice of office space. Do you envy it?
- Openfire 3.8.2 cluster configuration
- [webapi] return dynamic list dynamic
- Is the VIP securities account of qiniu school really safe and regular? How do I say this?
猜你喜欢
![Sword finger offer:[day 2 linked list (simple)] --- > reverse linked list](/img/05/0d7ed95f83c2188d274dde84817dc3.jpg)
Sword finger offer:[day 2 linked list (simple)] --- > reverse linked list
![[software test] 2022 national unified college enrollment examination](/img/9a/d76d7eb30a097d364fef28c2230e1a.png)
[software test] 2022 national unified college enrollment examination

Adding a markdown editor to lavel

零基础自学SQL课程 | SQL中的日期函数大全

docker下载Mysql镜像创建数据库链接时候发生密码错误问题

Microsoft's exclusive payment function has also been perfectly unlocked

Laravel文档阅读笔记-Adding a Markdown editor to Laravel

终于有人把云原生架构讲明白了

In one sentence, I will tell you the meaning of select 1, 2 and 3 in SQL injection, and explain the meaning of each part of SQL injection in detail

Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
随机推荐
F1tenth gym of ROS 2 humble hawksbill
QStringLiteral(str)
Activate function
加刚干的前提
Postman introduction and installation steps
LeetCode116. Populate the next right node pointer for each node
Smarca2 antibody study: abnova smarca2 monoclonal antibody protocol
IDC:阿里云获2021中国数据治理平台市场份额第一
关于杠杆的思考
SqlTransaction
Study on bifunctional crosslinker lumiprobe sulfoacyanine 7 dicarboxylic acid
Sword finger offer:[day 2 linked list (simple)] --- > reverse linked list
LeetCode188. The best time to buy and sell stocks IV
Sword finger offer:[day 2 linked list (simple)] --- > print the linked list from end to end
彪马携手10KTF Shop启动其迄今为止规模首屈一指的Web3合作项目
User network model and QoE
go-cryptobin 常用加密解密库
CORBA Architecture Guide (Common Object Request Broker Architecture)
16 `bs object Node name Div. attribute contents ` children descendants get child nodes and descendants
wrk压力测试工具介绍