CF1096:D. Easy Problem(DP)】的更多相关文章

Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length n consisting of lowercase Latin latters. Vasya thinks that the statement can be considered hard if it contains a subsequence har…
D. Easy Problem dp(有衔接关系的dp(类似于分类讨论) ) 题意 给出一个串 给出删除每一个字符的代价问使得串里面没有hard的子序列需要付出的最小代价(子序列不连续也行) 思路 要满足hard 先要满足har 要满足har 先要满足ha 一次类推 这类问题的一个共同点是要每个地方都要满足一系列前置条件才能成立也就是说有衔接关系 所以如果是构造问题 那么dp数组加一维已经满足了几个,如果是删除问题dp数组加一维 切断了哪一个即可 所以我们可以设置dp数学 dp[i][1,2,3…
题目链接:http://codeforces.com/problemset/problem/1096/D 题意: 给出一个小写字母组成的字符串,如果该字符串的某个子序列为 $hard$,就代表这个字符串是不好的. 现在你要删掉若干字母,使得字符串是好的,同时删除第 $i$ 个字母会使得歧义程度增加 $a[i]$,你需要让歧义程度最低,输出这个值. 题解: $dp[i][x=0,1,2,3]$ 的状态是前 $i$ 个字母,第二维 $x$ 代表:$0$——不包含任何有可能构成 “$hard$” 的子…
题意:给出一个字符串,去掉第i位的花费为a[i],求使字符串中子串不含hard的最小代价. 题解:这题的思路还是比较套路的,    dp[i][kd]两维,kd=0表示不含d的最小花费,1表示不含rd的,2表示不含ard的,3表示不含hard的 那么转移方程就显而易见了,一言概之就是如果前面没有,我这也要没有,就这位一定要去,否则不用去 代码如下: #include<bits/stdc++.h> using namespace std; ]; ]; ][]; int main() { scan…
题目地址:CF1096D Easy Problem 比赛时高二dalaoLRZ提醒我是状压,然而,我还是没AC (汗 其实是一道很基础的线性dp \(f_{i,j}\) 表示序列第 \(i\) 个字符时对于 \(string\ st="hard"\) 的前缀 \(0\) ~ \(j-1\) 最小的ambiguity值 边界: \(f_0=0\) ,其它 \(f\) 值均为 \(∞\) 状态转移方程: 若 \(s_i≠st_{j-1}\) ,则 \(f_{i,j}=f_{i-1,j}\)…
Easy Tree DP? Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1460    Accepted Submission(s): 557 Problem Description A Bear tree is a binary tree with such properties : each node has a value o…
An easy problem A Time Limit: 1000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Problem Description N个数排成一列,Q个询问,每次询问一段区间内的数的极差是多少. Input 第一行两个整数N(1≤N≤50000),Q(1≤Q≤200000).接下来一行N个整数a1 a2 a3 -.an,(1≤ai≤1000000000).接下来Q行,每行两个整数L,R(1≤L…
Easy Tree DP? Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1487    Accepted Submission(s): 567 Problem Description A Bear tree is a binary tree with such properties : each node has a value o…
Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu's Presents 1 and 2), he occasionally sets…
An easy problem Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’s 1 cup of water plus 1 pile of d…