bzoj1260
来源:互联网 发布:仓库软件多少钱 编辑:程序博客网 时间:2024/06/09 23:20
区间dp
最近一直在做水的dp
白天要上课。。。时间好少
#include<bits/stdc++.h>using namespace std;#define FOR(i,s,t) for(int i=(s);i<=(t);i++)inline int read(void){ int x = 0, c, f = 1; do{c=getchar();if(c=='-')f=-1;}while(c<'0'||c>'9'); do{x=x*10+c-'0';c=getchar();}while(c>='0'&&c<='9'); return x * f;}const int N = 60, INF = 0x3f3f3f3f;char s[N];int f[N][N], n;void DP(void) { for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) f[i][j] = i==j ? 1 : INF; for (int i = 2; i <= n; i++) { for (int l=1,r=i; r <= n; r++,l++) { if (s[l] == s[r]) { f[l][r] = min(f[l+1][r], f[l][r-1]); f[l][r] = min(f[l+1][r-1]+1,f[l][r]); } else for (int d = l; d < r; d++) { f[l][r] = min(f[l][r], f[l][d] + f[d+1][r]); } } }} int main(){ scanf("%s",s+1); n = strlen(s + 1); DP(); cout << f[1][n] << endl;}
阅读全文
0 0
- BZOJ1260
- BZOJ1260
- bzoj1260
- 【bzoj1260】 [CQOI2007]涂色paint
- bzoj1260(区间dp)
- BZOJ1260: [CQOI2007]涂色paint
- bzoj1260 [CQOI2007]涂色paint
- bzoj1260: [CQOI2007]涂色paint
- BZOJ1260涂色paint
- 【bzoj1260】[CQOI2007]涂色paint
- bzoj1260 [CQOI2007]涂色paint
- 【BZOJ1260】【CQOI】涂色paint
- [bzoj1260][dp]涂色
- BZOJ1260 [CQOI2007]涂色paint
- *bzoj1260 [CQOI2007] 涂色paint 题解
- bzoj1260: [CQOI2007]涂色paint dp
- 【bzoj1260】【CQOI2007】【涂色paint】【dp】
- 【BZOJ1260】[CQOI2007]涂色paint 【区间DP】
- 深入理解JavaScript系列(30):设计模式之外观模式
- android.os.Debug.waitForDebugger()使用需小心
- mysql索引
- hadoop 入门
- C++----声明、定义、const限定符
- bzoj1260
- problemdetail.do?&method=showdetail&id=5131
- Spring AOP 实现原理
- There's no Qt version assigned to this project for platform Win32
- 【剑指offer】把字符串转换成整数
- java----HashMap
- linux系统下守护进程的概念与实现简介
- 深入理解JavaScript系列(31):设计模式之代理模式
- Code Vs-problem-1204 寻找子串位置