POJ3280 Cheapest Palindrome
来源:互联网 发布:韩国高考难度知乎 编辑:程序博客网 时间:2024/05/16 13:55
DP#include<cstdio>#include<iostream>#include<stdlib.h>#include<ctype.h>#include<algorithm>#include<cmath>#include<cstring>#include<queue>#include<iomanip>#include<set>#include<string>#include<iterator>#define maxn 10000000using namespace std;int N,M;int dp[2010][2010];int cost[30];string str;void solve(){ memset(dp,0,sizeof(dp)); for(int i=M-1;i>=0;i--)// 倒着来 for(int j=i;j<M;j++) if(str[i]==str[j])//****// dp[i][j]=dp[i+1][j-1]; else dp[i][j]=min(dp[i+1][j]+cost[str[i]-'a'],dp[i][j-1]+cost[str[j]-'a']);}int main(){ while(cin>>N>>M){ cin>>str; char c; int a,b; for(int i=0;i<N;i++){ cin>>c>>a>>b; cost[c-'a']=min(a,b); } solve(); cout<<dp[0][M-1]<<endl; }}
- POJ3280 Cheapest Palindrome
- POJ3280 Cheapest Palindrome
- poj3280 Cheapest Palindrome
- POJ3280 Cheapest Palindrome 【DP】
- POJ3280 Cheapest Palindrome
- [dp] poj3280 Cheapest Palindrome
- 【POJ3280】【Cheapest Palindrome】
- POJ3280--Cheapest Palindrome
- poj3280 Cheapest Palindrome
- poj3280 Cheapest Palindrome
- POJ3280-Cheapest Palindrome
- poj3280 Cheapest Palindrome
- POJ3280 Cheapest Palindrome
- POJ3280-Cheapest Palindrome
- POJ3280:Cheapest Palindrome(区间DP)
- POJ3280 Cheapest Palindrome 区间DP
- 区间dp poj3280 Cheapest Palindrome
- poj3280 Cheapest Palindrome(区间dp)
- VS2010中的自动化测试(3)——数据驱动的单元测试
- DNS服务检测
- 软件开发管理之思考
- VS2010中的自动化测试(4)——Web性能测试
- opencv2.4.2+vs2010安装简介
- POJ3280 Cheapest Palindrome
- cp: omitting directory”错误的解释和解决办法
- 求素数的第N种境界的实现(需求1)
- c#哈希表的用法
- 电子游戏与心理学的探讨
- 今日总结之 Android小技巧
- MySql错误处理----------- 错误代码和消息
- 操作系统学习,第五章,设备管理
- AJAX(1)