POJ 1795】的更多相关文章

[题目链接] http://poj.org/problem?id=1795 [题目大意] 给出n个字符串,求一个最小长度的串,该串包含给出的所有字符串. 要求长度最小且字典序最小. [题解] dp[i][s]表示包括s集合字符串的第i个字符串为开头的最小值 从后往前贪心得到最小值,然后从前往后搜索得出最小字典序的答案 [代码] #include <iostream> #include <cstring> #include <algorithm> #include <…
DNA Laboratory Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 1425   Accepted: 280 Description Background Having started to build his own DNA lab just recently, the evil doctor Frankenstein is not quite up to date yet. He wants to extra…
题意:给定 n 个 字符串,让你构造出一个最短,字典序最小的字符串,包括这 n 个字符串. 析:首先使用状压DP,是很容易看出来的,dp[s][i] 表示已经满足 s 集合的字符串以 第 i 个字符串结尾,他很容易就求得最短长度,但是这个字符串怎么构造呢, 由于要字典序最小,所以就不好搞了,挺麻烦的,所以我们利用贪心的思路,我们可以这样定义,dp[s][i] 表示已经满足 s 集合的字符串以 第 i 个字符串开头, 从后向前放,状态转移方程为:dp[s|(1<<i)][i] = min{ dp…
DNA Laboratory Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 2892   Accepted: 516 Description Background Having started to build his own DNA lab just recently, the evil doctor Frankenstein is not quite up to date yet. He wants to extra…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…