动态规划
文章平均质量分 69
ciel_s
这个作者很懒,什么都没留下…
展开
-
hdu 5495 Fxx and game(dp+单调队列优化)
bestcoder#89 的第二题……初测过了,终测全部挂掉了…… 本来以为是贪心,后来才发现是dp,要用单调队列维护。 看了学霸的代码,单调队列的模板就借用了╭(╯^╰)╮代码如下:#include <iostream>#include <string>#include <cstring>#include <cstdio>#include <queue>#include <algor原创 2016-10-30 22:40:29 · 370 阅读 · 0 评论 -
hdu 2476 String painter(区间dp)
Problem DescriptionThere are two strings A and B with equal length. Both strings are made up of lower case letters. Now you have a powerful string painter. With the help of the painter, you can change原创 2017-03-11 18:47:19 · 217 阅读 · 0 评论 -
zoj 3469 Food Delivery(区间dp)
题目链接When we are focusing on solving problems, we usually prefer to stay in front of computers rather than go out for lunch. At this time, we may call for food delivery.Suppose there are N people living原创 2017-03-13 20:31:18 · 292 阅读 · 0 评论 -
hdu 4734 F(x) 数位dp
题目链接Problem DescriptionFor a decimal number x with n digits (AnAn-1An-2 … A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + … + A2 * 2 + A1 * 1. Now you are given two numbers A and B, ple原创 2017-03-26 21:35:48 · 393 阅读 · 0 评论 -
2017WHU校赛OL Werewolf (基环外向树)
题目链接题目大意:有n个玩家,编号1~n,已知狼人不会投狼人,其他人可能投任何人,给你一局投票的情况,判断最多有多少狼人。比赛时没有什么思路,题解说是基环外向树,第一次听到这个名词感觉十分高端,搜了一下才发现这个东西就是一颗普通的树再加上一条边,那么一定会在这个树里形成一个环,外向树是说其他链的方向指向外,内向树则是指向内。对于n个玩家,每个人投一票,构成的关系便有n条边,这些点不一定是相互连通的,原创 2017-04-12 22:00:01 · 480 阅读 · 0 评论 -
poj 2686 Traveling by Stagecoach (状压dp)
DescriptionOnce upon a time, there was a traveler. He plans to travel using stagecoaches (horse wagons). His starting point and destination are fixed, but he cannot determine his route. Your job in thi原创 2017-04-04 19:51:45 · 342 阅读 · 0 评论 -
poj 2441 Arrange the Bulls(状压dp)
Farmer Johnson’s Bulls love playing basketball very much. But none of them would like to play basketball with the other bulls because they believe that the others are all very weak. Farmer Johnson has原创 2017-04-04 20:11:39 · 364 阅读 · 0 评论 -
poj 3254 Corn Fields(状压dp)
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 yummy corn for the cows on a number of squares. Regrettably, s原创 2017-04-04 20:20:47 · 209 阅读 · 0 评论 -
poj 2836 Rectangular Covering (状压dp)
n points are given on the Cartesian plane. Now you have to use some rectangles whose sides are parallel to the axes to cover them. Every point must be covered. And a point can be covered by several rec原创 2017-04-04 20:49:57 · 268 阅读 · 0 评论 -
zoj 3777 Problem Arrangement(状压dp)
题目链接The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order of the problems. As we know, the arrangement will have a great effec原创 2017-04-16 22:53:13 · 425 阅读 · 0 评论 -
hdu 6006 Engineer Assignment(状压dp)
题目链接Problem DescriptionIn Google, there are many experts of different areas. For example, MapReduce experts, Bigtable experts, SQL experts, etc. Directors need to properly assign experts to various pro原创 2017-04-24 15:48:53 · 1273 阅读 · 0 评论 -
hdu 6024 Building Shops (dp)
题意:有n个教室,从左到右建若干糖果屋,要求每个教室的本身或者左边至少有一个糖果屋,如果在这个点建糖果屋,花费为每个点的c,如果不建,花费为这个点到左边最近的糖果屋距离。求最小花费。很明显是一道dp的题目,然而在比赛的时候却没有做出来,而且思路是完全偏了……所以挣扎了很长时间也没做出来,还是觉得自己好菜啊……dp状态的定义其实是关键……如果状态定义对了,转移方程就很好想了,但是比赛的时候不知道为什么原创 2017-05-08 20:02:53 · 466 阅读 · 0 评论 -
CodeForces - 149D Coloring Brackets(区间dp)
题目链接这是一道区间dp的题目……怎么说呢,让我认识到我之前对区间dp的理解太浅显和模式化了,总觉得就是枚举每个区间段就可以了, ==确实是我刷的题还太少。 这道题目也是对于这些颜色该怎么处理无从下手,看完题解才觉得好巧妙。dp[rl[r][prel][prer],用这个数组来表示每个区间的状态,prel prer即代表这个区间外的紧挨的两个括号的颜色,有三种状态0 1 2,0为不染色,1为红色,原创 2017-03-10 18:15:25 · 253 阅读 · 0 评论 -
hdu 4283 You Are the One(区间dp)
题目链接Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hal原创 2017-03-10 17:55:43 · 231 阅读 · 0 评论 -
POJ 1160 Post Office(dp)
Post OfficeTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 18758 Accepted: 10113戳这里题目链接Description There is a straight highway with villages alongside the highway. The highwa原创 2016-09-20 19:38:07 · 275 阅读 · 0 评论 -
poj 1741 Tree (树的分治)
TreeTime Limit: 1000MS Memory Limit: 30000K Total Submissions: 20776 Accepted: 6803DescriptionGive a tree with n vertices,each edge has a length(positive integer less than 1001). Define原创 2017-02-20 17:03:08 · 347 阅读 · 0 评论 -
poj 2152 Fire(树形dp)
DescriptionCountry Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so t原创 2017-02-22 01:49:26 · 411 阅读 · 0 评论 -
hdu2196 Computer (树形dp)
题目链接A school bought the first computer some time ago(so this computer’s id is 1). During the recent years the school bought N-1 new computers. Each new computer was connected to one of settled earlier.原创 2017-02-14 16:34:20 · 384 阅读 · 0 评论 -
poj 2486 Apple Tree (树形dp)
DescriptionWshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. There are N nodes in the tree. Each node has an amount of apples. Wshxzt starts her happy trip at o原创 2017-02-22 23:08:04 · 252 阅读 · 0 评论 -
hdu 4003 Find Metal Mineral(树形dp+分组背包)
Problem DescriptionHumans have discovered a kind of new metal mineral on Mars which are distributed in point‐like with paths connecting each of them which formed a tree. Now Humans launches k robots on原创 2017-02-23 19:08:14 · 289 阅读 · 0 评论 -
hdu 1561 The more, The Better(树形dp+分组背包)
Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input 每个测试实例首先包括2个整数,N,M.(1 <= M <= N原创 2017-02-15 23:32:10 · 225 阅读 · 0 评论 -
hdu 1011 Starship Troopers (树形背包)
Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected with原创 2017-02-24 15:25:55 · 235 阅读 · 0 评论 -
hdu 5745 La Vie en rose(bitset优化dp)
题目链接去年多校赛的一道题目,今天下午拿来训练的时候做的,刚开始题意卡了半天,根本没有看懂,后来才发现那个下标的大小决定了我们题目理解的是否正确== 总之大意就是,有一串长字符s,短字符p,p中相邻的字母可以进行交换但不能重复交换,问以s的每个字符开头是否能匹配p或者p的变形。理解题意后发现这道题的思路还是相当简单的,就是一个很普通的dp,但是问题是数据规模,正常的dp时间复杂度为o(m*n),5原创 2017-03-05 00:04:15 · 511 阅读 · 0 评论 -
poj 1947 Rebuilding Roads (树形背包)
DescriptionThe cows have reconstructed Farmer John’s farm, with its N barns (1 <= N <= 150, number 1..N) after the terrible earthquake last May. The cows didn’t have time to rebuild any extra roads, so原创 2017-02-26 22:56:28 · 316 阅读 · 0 评论 -
zoj 3537 Cake (凸包 最优三角剖分)
题目链接这道题目是一道最优三角剖分的题目,其实也是一种区间dp里的一种应用,思路也很简单。这道题目还需要先是不是凸包,这里其实主要想记录一下凸包模板==#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const dou原创 2017-03-19 18:53:05 · 424 阅读 · 0 评论 -
hdu 2089 不要62 (数位dp入门)
题目链接Problem Description杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 88914 都属于不吉利号码。但是,61152虽然含有6原创 2017-03-19 20:43:55 · 327 阅读 · 0 评论 -
hdu 6170 Two strings (dp)
题目链接刚开始想用模拟的方法去做,但是*的处理比较麻烦就很难写。后来用dfs 的方法去写结果会超时…… 比赛结束之后看题解说是dp,然后就去往这个方向思考,然后发现dp确实能做= =用dp[i][j]表示b[i]和a[j]是否匹配。 if b[i]==a[j]||b[i]==’.’ dp[i][j]=dp[i-1][j-1] ;if b[i]==’*’ 此时b[i-1]可以出现0次或1次或更多原创 2017-08-23 16:07:12 · 288 阅读 · 0 评论