51nod 1154 回文串划分
来源:互联网 发布:全境封锁优化怎么样 编辑:程序博客网 时间:2024/05/29 19:55
#include <bits/stdc++.h>using namespace std;string str;int dp[5050];int main(){int i,lef,rig;while(cin>>str){for(i=0;i<str.length();i++)dp[i]=i+1;for(i=0;i<str.length();i++){for(lef=i,rig=i;lef>=0&&rig<str.length();lef--,rig++){if(str[lef]==str[rig])dp[rig]=min(dp[rig],1+(lef==0?0:dp[lef-1]));elsebreak;}for(lef=i,rig=i+1;lef>=0&&rig<str.length();lef--,rig++){if(str[lef]==str[rig])dp[rig]=min(dp[rig],1+(lef==0?0:dp[lef-1]));elsebreak;}}printf("%d\n",dp[str.length()-1]);}}
0 0
- 51nod 1154 回文串划分 (DP)
- 51nod 1154:回文串划分
- 51nod 1154 回文串划分
- 51Nod 1154 回文串划分
- 51 Nod 1154 回文串划分
- 51nod 1154 回文串划分
- 【dp】51nod 1154 回文串划分
- 51nod-1154-回文串划分
- 【51nod】1154 回文串划分
- 51nod 1154 回文串划分
- 51nod 1154回文串划分 dp+递推
- 51Nod-1154-回文串划分
- 【51Nod】1154 - 回文串划分(dp)
- 51NOD 1154 回文串划分 【DP+Manacher】
- 51nod 1154 回文串划分(dp)
- 1154 回文串划分
- 1154 回文串划分
- 51nod1154回文串划分
- 快速排序
- 51nod 1138 连续整数的和
- 宏和函数的区别
- 八大排序 -- 插入排序 之 【shell排序】
- linux驱动模型
- 51nod 1154 回文串划分
- 数据结构实验之串三:KMP应用
- 软工文档总结
- 【Java每日一题】20161103
- DOS批处理]for 命令 /f 参数 通俗讲解(转发)
- 51nod 1163 最高的奖励
- window 10 桌面显示计算机的操作
- Ntrip通讯协议1.0
- 数论算法总结01