dp
ffutop
这个作者很懒,什么都没留下…
展开
-
Ural 1002 Phone Number (字典树 + dp)
题意给定一串数字,表示在手机九宫格按键下的输入,同时给定 n 串可能产生的单词,问九宫格输入是否能够产生仅使用给定单词的一段话,同时要求产生的语句的单词数量最少。若不能,则输出 No solution.分析对于给定的 n 串单词,均用字典树的结构加以保存,要求在插入的同时将字母转换成对应的数字。在完成建树后,考虑简单动规解决匹配产生的单词数最少的问题。dp[i]=dp[j]+1dp[i] = dp[原创 2017-02-23 09:11:16 · 460 阅读 · 0 评论 -
HDU 6076 Security Check (DP, 2017 Multi-Univ Training Contest 4)
Problem两列队伍,每队 N 人,A 队每人 rank 为 aia_i ,B 队每人 rank 为 bib_i,要求从队首向队尾顺次检查(完成检查的即离队),每次检查可以是下列两种操作的任一种:任选一个队伍的队首检查(如果该队非空)如果两队队首 ∣ai−bi∣>K\mid a_i-b_i\mid \gt K ,则可以同时检查两队队首。Limit1≤N≤600001\le N\le 6000原创 2017-08-06 11:11:13 · 661 阅读 · 0 评论 -
HDU 6078 Wavel Sequence (dp + 树状数组, 2017 Multi-Univ Training Contest 4)
Problem含 N 个数的 a 数组 a1,a2,⋯,ana_1, a_2,\cdots, a_n 和含 M 个数的 b 数组 b1,b2,⋯,bmb_1, b_2,\cdots, b_m ,求有多少 a,b 公共子序列(记作 arr, 长为 len )满足 arr1<arr2>arr3<arr4>arr5⋯arr_1 \lt arr_2\gt arr_3\lt arr_4 \gt arr_5\c原创 2017-08-04 10:02:29 · 673 阅读 · 0 评论 -
Codeforces Gym 100825 G. Tray Bien (DP)
Problem3×m3\times m 的矩形框,有 1×11\times 1 和 1×21\times 2 两种尺寸的小块,求用其填充矩形框的方案数。有 n 个坏点 (x, y) 存在,要求其所在的 1×11\times 1 格子块不能填充。限制条件1≤m≤241\le m \le 240<x<m0 \lt x \lt m0<y<30\lt y \lt 3解题思路dp[i][j] 表示前 i原创 2017-07-19 16:59:05 · 614 阅读 · 0 评论 -
Codeforces Round #426 (Div. 1) B. The Bakery (DP + 线段树)
Problem将 N 长序列划分 K 块的最大价值和。每块的价值定义为该段区间内的不同数的个数。其中 N 长序列的每个数为 a1,a2,⋯,ana_1, a_2,\cdots,a_nLimit1≤N≤350001\le N \le 350001≤K≤min(n,50)1\le K \le \min(n, 50)1≤ai≤N1\le a_i \le NIdea从数据限制来看,此题的复杂度一般应该在 O原创 2017-07-31 14:10:34 · 690 阅读 · 0 评论 -
Codeforces Gym 101174 D. Dinner Bet (期望 + DP)
Problem一黑盒中有 N 个球,每球标号分别为 1~N 。游戏根据下列步骤进行:初始时刻,两个人从 1~N 中选择 C 个不同的数字并记录。在每轮游戏中,完全随机地从黑盒中同时取出 D 个球,同时两人标记自己的 C 个数字中恰好是抽出的某一球编号的数字。后将 D 个球放回。当至少有一人的 C 个数全部被标记,游戏结束。问游戏结束的期望轮次。限制条件1 ≤ N ≤ 50 1 ≤ D ≤ m原创 2017-07-14 16:55:02 · 786 阅读 · 0 评论 -
Codeforces Gym 101190 (NEERC 2016) F. Foreign Postcards (dp + 期望)
F - Foreign Postcards题意对于一叠 n 张卡片,随机取前 k 张若取到的 k 张的第一张为 W ,则 k 张卡片的状态全部翻转。将 k 张卡片在桌面上展示若一叠卡片仍有剩余,则继续上述操作问最后桌面上为 W 的卡片的期望?解题思路首先计算对于第 i 张卡片,其为 k 张中的第一张的概率,依次为 1, 1n\frac{1}{n} , 1n−1\frac{1}{n-1},原创 2017-06-25 10:28:56 · 1317 阅读 · 0 评论 -
HDU 6030 Happy Necklace (DP)
Little Q wants to buy a necklace for his girlfriend. Necklaces are single strings composed of multiple red and blue beads. Little Q desperately wants to impress his girlfriend, he knows that she will原创 2017-05-10 14:28:54 · 685 阅读 · 0 评论 -
HDU 6024 Building Shops (DP)
题意n 间教室坐落在一维坐标轴上,其中若干间将被改造成糖果屋。已知每间教室的坐标 xix_i 以及改造费用 cic_i 。其中费用计算分两类:所有改造为糖果屋的教室需花费 cic_i 需要对所有未改造的教室,每间教室 P 支付费用为 当前教室坐标 - 其左侧离其最近的糖果屋的坐标 。其中要求 n 间中最左一间必须改造为糖果屋。问改造的最小费用?解题思路动规。令 dp[i][j] 表示前 i 间原创 2017-05-09 10:05:05 · 892 阅读 · 0 评论 -
ZOJ 3962 Seven Segment Display (数位 DP)
A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. Seven segment原创 2017-04-25 08:55:25 · 569 阅读 · 0 评论 -
Codeforces Round #371 C. Sonya and Problem Wihtout a Legend (DP)
题意Sonya was unable to think of a story for this problem, so here comes the formal description.You are given the array containing n positive integers. At one turn you can pick any element and increase o原创 2017-05-05 14:44:41 · 457 阅读 · 0 评论 -
ZOJ 3956 Course Selection System (dp)
There are n courses in the course selection system of Marjar University. The i-th course is described by two values: happiness Hi and credit Ci. If a student selects m courses x1, x2, …, xm, then his c原创 2017-04-12 11:16:43 · 1447 阅读 · 0 评论 -
UVA 10934 Dropping water balloons (动规)
DescriptionIt’s frosh week, and this year your friends have decided that they would initiate the new computer science students by dropping water balloons on them. They’ve filled up a large crate of ide原创 2017-03-09 12:11:14 · 488 阅读 · 0 评论 -
HDU 6199 gems gems gems (DP, 2017 ACM/ICPC Asia Regional Shenyang Online)
ProblemNow there are n gems, each of which has its own value. Alice and Bob play a game with these n gems. They place the gems in a row and decide to take turns to take gems from left to right. Alic原创 2017-09-11 09:01:14 · 1855 阅读 · 12 评论