当前位置:网站首页>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;
}边栏推荐
- IPv6 comprehensive experiment
- 终于有人把云原生架构讲明白了
- Building web automation environment
- YAYA LIVE CTO 唐鸿斌:真正本地化,要让产品没有「产地」属性
- Study on luminiprobe non fluorescent azide -- 3-azido propanol
- Explanation and usage of sqrt() function
- LeetCode123. The best time to buy and sell stocks III
- 给朋友的忠告
- #yyds干货盘点# 解决剑指offer: 连续子数组的最大和(二)
- Interface test process
猜你喜欢

城市大脑知识图谱构建及应用研究

直播预告|SQL也能玩转工业级机器学习?MLOps meetup V3带你一探究竟!

小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
![[software test] 2022 national unified college enrollment examination](/img/9a/d76d7eb30a097d364fef28c2230e1a.png)
[software test] 2022 national unified college enrollment examination

16 `bs object Node name Div. attribute contents ` children descendants get child nodes and descendants

AI deep dive of Huawei cloud

After reading the list of global patent and chip buyers, I understand that high innovation can lead to high profits

Anti rabbit dylight 488 abbkine universal immunofluorescence (if) toolbox

CVPR 2022|极具创意&美感的文字生成方法!支持任意输入

docker下载Mysql镜像创建数据库链接时候发生密码错误问题
随机推荐
Study on luminiprobe non fluorescent azide -- 3-azido propanol
LeetCode122. The best time to buy and sell stocks II
SQLSERVER sys. Escape of parameter placeholders in messages
Lumiprobe proteorange protein gel dye instructions
Interface test process
运维体系建设思考 - 稳定性篇
Sword finger offer:[day 1 stack and queue (simple)] --- > use two stacks to realize the queue
LeetCode560. Subarray with and K
PE file-
Why use the rust language?
PHP uses stack to solve maze problem
PHP login problem
Workplace tips | understanding the advantages of the position "knowing people"
2022年股票在手机上开户安全吗?找谁可以办理?
Wechat applet realizes left sliding deletion
Comprehensive evaluation of easy-to-use and powerful PDF reading software: PDF expert, marginnote, liquidtext, notability, goodnotes, Zotero
零基础自学SQL课程 | SQL中的日期函数大全
[width first search note] BFS output shortest path
Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
QT 一个控件的坐标怎么相对固定显示在另一个控件上(坐标系)