Codeforces 354B dp Game with Strings dp】的更多相关文章

题目链接:http://codeforces.com/contest/682/problem/D 给你两个字符串,求两个字符串中顺序k个的相同子串 长度之和.(注意是子串) dp[i][j][k][0] 表示a[i] == a[j]时,a字符串前i个和b字符串前j个,顺序k个相同的子串 长度之和 dp[i][j][k][1] 表示a[i] != a[j]时,顺序k个相同子串的长度之和 dp[i][j][k][0] = max(dp[i - 1][j - 1][k][0], dp[i - 1][j…
题目链接: D. Alyona and Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n a…
Game with Strings 题意并不是在图上走,看了好久才看出来.. dp[ i ][ mask ]表示从 i 层开始走,起点有mask个, a的个数-b的个数的  最大值或者最小值. #include<bits/stdc++.h> #define LL long long #define LD long double #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL&g…
题目链接: http://www.codeforces.com/contest/476/problem/E E. Dreamoon and Strings time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining…
题目 Source http://codeforces.com/contest/467/problem/C Description The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced t…
题目链接: http://codeforces.com/contest/161/problem/D D. Distance in Tree time limit per test 3 secondsmemory limit per test 512 megabytes 问题描述 A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is th…
题目链接:http://codeforces.com/contest/479/problem/E 题意:         给定一个启示的楼层a,有一个不能去的楼层b,对于你可以去的下一个楼层必须满足你当前楼层x与下一个要去的楼层y的距离小于x到b的距离.求出走k趟的方案数. 题解: dp[i][j]  表示第i趟 在第j层楼的方案数.一般用三个for才可以,所以我们用前缀和优化一下,时间复杂度降到O(n*k).空间复杂度有点大,所以我们可以用滚动数组. //#pragma comment(lin…
题目链接:http://codeforces.com/contest/118/problem/D 有n个步兵和m个骑兵要排成一排,其中连续的步兵不能超过k1个,连续的骑兵不能超过k2个. dp[i][j][x][y]表示表示用i个步兵和j个骑兵,末尾有连续的x个步兵,或者有连续的y个骑兵. 所以x > 0 && y > 0的情况不存在.三个for就好了. #include <bits/stdc++.h> using namespace std; typedef lo…
题目链接:http://codeforces.com/problemset/problem/710/E 加或者减一个字符代价为x,字符数量翻倍代价为y,初始空字符,问你到n个字符的最小代价是多少. dp[i]表示i个字符的最小代价. 当i为偶数个的时候,由+1或者*2得到. 当i为奇数个的时候,由+1或者*2-1得到. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm>…
题目链接:http://codeforces.com/problemset/problem/148/D 题意: 原来袋子里有w仅仅白鼠和b仅仅黑鼠 龙和王妃轮流从袋子里抓老鼠. 谁先抓到白色老师谁就赢. 王妃每次抓一仅仅老鼠.龙每次抓完一仅仅老鼠之后会有一仅仅老鼠跑出来. 每次抓老鼠和跑出来的老鼠都是随机的. 假设两个人都没有抓到白色老鼠则龙赢.王妃先抓. 问王妃赢的概率. 解析: 设dp[i][j]表示如今轮到王妃抓时有i仅仅白鼠,j仅仅黑鼠.王妃赢的概率 明显 dp[0][j]=0,0<=j…