ZOJ2401 Zipper 双塔式 DP(双塔DP)】的更多相关文章

第二次遇到双塔DP,再写一下. (flag是为了避免memset多次导致的时间浪费) #include<cstdio> #include<cstdlib> #include<iostream> #include<cstring> using namespace std; ],y[],z[]; ][],L,Lx;//410=210+x bool _find(int flag) { ;i<=L;i++) { ;j<=min(Lx,i);j++) ][…
遇到双塔DP,写一下. flag是为了避免memset多次导致的时间浪费. #include<cstdio> #include<cstdlib> #include<iostream> #include<cstring> using namespace std; char x[410],y[410],z[410]; int map[410][410],L,Lx;//410=210+x bool _find(int flag) { for(int i=1;i&l…
描述 2001年9月11日,一场突发的灾难将纽约世界贸易中心大厦夷为平地,Mr. F曾亲眼目睹了这次灾难.为了纪念“9?11”事件,Mr. F决定自己用水晶来搭建一座双塔. Mr. F有N块水晶,每块水晶有一个高度,他想用这N块水晶搭建两座有同样高度的塔,使他们成为一座双塔,Mr. F可以从这N块水晶中任取M(1≤M≤N)块来搭建.但是他不知道能否使两座塔有同样的高度,也不知道如果能搭建成一座双塔,这座双塔的最大高度是多少.所以他来请你帮忙. 给定水晶的数量N(1≤N≤100)和每块水晶的高度H…
Greedy Tino Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1194    Accepted Submission(s): 393 Problem Description   Tino wrote a long long story. BUT! in Chinese...   So I have to tell you th…
Ferry Loading Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1807   Accepted: 509   Special Judge Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run…
Process the Tasks Time Limit: 1 Second      Memory Limit: 32768 KB There are two machines A and B. There are n tasks, namely task 1, task 2, ..., task n. You must assign each task to one machine to process it. There are some facts you must know and c…
The Twin Towers Time Limit: 2 Seconds      Memory Limit: 65536 KB Twin towers we see you standing tall, though a building's lost our faith will never fall. Twin towers the world hears your call, though you're gone it only strengthens our resolve. We…
Jury Compromise Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 33737   Accepted: 9109   Special Judge Description In Frobnia, a far-away country, the verdicts in court trials are determined by a jury consisting of members of the general…
题目链接 题意: 给n长度的S串,对于0<=i<=|S|,有多少个长度为m的T串,使得LCS(S,T) = i. 思路: 理解的不是很透彻,先占个坑. #include <bits/stdc++.h> const int S = (1 << 15) + 5; const int MOD = 1e9 + 7; char color[] = "ATGC"; char s[20]; int pre[20], lcs[20]; int dp[2][S], a…
问题问的是最少可以把一个字符串分成几段,使每段都是回文串. 一开始想直接区间DP,dp[i][j]表示子串[i,j]的答案,不过字符串长度1000,100W个状态,一个状态从多个状态转移来的,转移的时候要枚举,这样时间复杂度是不可行的. 然后我就想降维度了,只能线性DP,dp[i]表示子串[0,i]的答案.这样可以从i-1转移到i,str[i]单独作一段或者str[i]能和前面的组成回文串,方程如下: dp[i]=min(dp[i-1]+1,dp[j-1]+1) (子串[j,i]是回文串) 现在…