当前位置:网站首页>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;
}边栏推荐
- LxC shared USB device
- How to analyze the relationship between enterprise digital transformation and data asset management?
- Multinomial distribution (a discrete distribution)
- How can the sports app keep the end-to-side background alive to make the sports record more complete?
- Leetcode56. consolidation interval
- Study on bifunctional crosslinker lumiprobe sulfoacyanine 7 dicarboxylic acid
- QT how the coordinates of one control are relatively fixed and displayed on another control (coordinate system)
- CORBA Architecture Guide (Common Object Request Broker Architecture)
- Web automation tool selection
- Activate function
猜你喜欢

What is an interface? What is interface testing?

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

CVPR 2022 𞓜 a creative and aesthetic text generation method! Support any input
![[webapi] return dynamic list dynamic](/img/83/b0b36ddab6d74ccd89811cbb58d051.jpg)
[webapi] return dynamic list dynamic

Recommend two high-quality Wallpaper software

Alist+raidrive gives the computer a complete 8billion GB hard disk drive

Construction and application of urban brain knowledge map

10、标准I/O输入输出重定向及管道

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

Survival of beaver: post-90s female doctors and AI developers
随机推荐
Real time transformer: meituan's research on single image depth estimation
彪马携手10KTF Shop启动其迄今为止规模首屈一指的Web3合作项目
Security dilemma of NFT liquidity agreement - Analysis of the hacked event of NFT loan agreement xcarnival
How can the sports app keep the end-to-side background alive to make the sports record more complete?
LeetCode1114. Print in sequence
Interface use case design
河狸生存记:90后女博士与AI开发者们
[software test] 2022 national unified college enrollment examination
17 `bs object Node name h3 Parent ` parents get parent node ancestor node
LeetCode116. Populate the next right node pointer for each node
How to analyze the relationship between enterprise digital transformation and data asset management?
Google search is dying | DKB
Architecture design of e-commerce secsha system
Multinomial distribution (a discrete distribution)
Deep interpretation of WiFi security vulnerability krack
开通股票炒股账号安全吗?是靠谱的吗?
Lumiprobe non fluorescent alkyne research - dbco NHS ester
运动App如何实现端侧后台保活,让运动记录更完整?
Hardware development notes (VII): basic process of hardware development, making a USB to RS232 module (VI): creating 0603 package and associating principle graphic devices
Webrtc audio and video development - experience