【DP】 Light OJ 1422 Halloween Costumes
来源:互联网 发布:grub2 引导linux 编辑:程序博客网 时间:2024/05/16 15:52
地址:点击打开链接
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <map>#define cler(arr, val) memset(arr, val, sizeof(arr))typedef long long LL;const int MAXN = 10000+6;const int MAXM = 140000;const int INF = 0x3f3f3f3f;const int mod = 1000000007;int a[122],dp[122][122];int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);#endif int t,n,cas=1; cin>>t; while(t--) { cin>>n; for(int i=1;i<=n;i++) scanf("%d",&a[i]); cler(dp,0); for(int i=1;i<=n;i++) dp[i][i]=1; for(int i=n-1;i>=1;i--) { for(int j=i+1;j<=n;j++) { dp[i][j]=dp[i+1][j]+1; for(int k=i+1;k<=j;k++) { if(a[i]==a[k]) dp[i][j]=min(dp[i][j],dp[i+1][k-1]+dp[k][j]); } } } printf("Case %d: %d\n",cas++,dp[1][n]); } return 0;}
0 0
- Light oj 1422 Halloween Costumes(区间 dp)
- Light OJ 1422 - Halloween Costumes (区间DP)
- Light oj 1422 Halloween Costumes 区间DP
- 【DP】 Light OJ 1422 Halloween Costumes
- Light OJ 1422 Halloween Costumes(区间DP)
- light oj 1422 Halloween Costumes (区间DP)
- Light oj 1422 Halloween Costumes
- Light oj 1422 - Halloween Costumes
- light oj 1422 - Halloween Costumes (区间dp)
- light oj 1422 Halloween Costumes(区间dp)
- Light OJ 1422 Halloween Costumes(区间DP)
- light oj 1422 Halloween Costumes (区间DP)
- Light OJ 1422 Halloween Costumes(区间DP)
- Light oj 1422 Halloween Costumes 区间DP ★★★
- Light OJ 1422 Halloween Costumes (区间DP)
- light oj Halloween Costumes
- Light oj 1422 Halloween Costumes(区间DP:迭代or记忆化搜索)
- Light oj1422 Halloween Costumes 区间DP
- DP--Longest Valid Parentheses
- poj3160(Tarjan+Spfa)
- WARNING: Phonon needs QCoreApplication::applicationName to be set to export audio output names throu
- linux c/c++ 后台开发常用组件之:高性能阻塞队列
- 设计模式之装饰模式
- 【DP】 Light OJ 1422 Halloween Costumes
- 【Leetcode】Valid Parentheses in JAVA——一个括号de了20分钟bug的故事
- centos Apache、php、mysql默认安装路径
- 使用栈在O(1)的时间复杂度求最大值
- Crack the Coding Interview[careerup150]正式启动!【倒计时30天】
- I009-黑马程序员_毕向东_Java基础视频教程第01天-09-Hello World的组成部分
- 64位centos6中安装、配置mysql5.6.x的教程
- 在Ubuntu上为Android系统编写Linux内核驱动程序
- Spring mvc @ResponseBody jquery ajax调用出现如下错误:406 Not Acceptable