HDU 3757 Evacuation Plan DP】的更多相关文章

跟 UVa 1474 - Evacuation Plan 一个题,但是在杭电上能交过,在UVa上交不过……不知道哪里有问题…… 将施工队位置和避难所位置排序. dp[i][j] 代表前 i 个避难所收留前 j 个施工队. dp[i][j] = min( dp[i - 1][j - 1], dp[i][j - 1] ) + abs( b[i] - a[j] ); 内存卡的比较死,要用滚动数组,并且记录路径的path[i][j]只能用bool型.MLE了四五次OTL…… #include <cstd…
Evacuation Plan Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4617   Accepted: 1218   Special Judge Description The City has a number of municipal buildings and a number of fallout shelters that were build specially to hide municipal w…
"Evacuation Plan" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description The City has a number of municipal buildings and a number of fallout shelters that were build specially to hide municipal workers in case …
题目链接:  HDU 1011 树形背包(DP) Starship Troopers 题意:  地图中有一些房间, 每个房间有一定的bugs和得到brains的可能性值, 一个人带领m支军队从入口(房间1)进入, 只有到达某个房间并且将bugs全部杀死, 才能得到相应该的值. 问最多能获得多少可能性值. PS  1). 一支军队能杀死 20 bugs,  当一支军队发生战争之后就不能再到其它地方去了 2) . 不能走回头路 分析:  [树形背包] 用dp[i][j]表示到达房间 i 的军队数为…
http://poj.org/problem?id=2175 Evacuation Plan Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3256   Accepted: 855   Special Judge Description The City has a number of municipal buildings and a number of fallout shelters that were build…
Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3180    Accepted Submission(s): 1033 Problem Description For the hope of a forever love, Steven is planning to send a ring to Jane with a rom…
一看就是状压,由于是类似博弈的游戏.游戏里的两人都是绝对聪明,那么先手的选择是能够确定最终局面的. 实际上是枚举最终局面情况,0代表是被Bob拿走的,1为Alice拿走的,当时Alice拿走且满足变换成魔法石,那么相当于是Alice完成了该次操作,增加上次状态值,否则相当于先后手交换,该状态下减去上个状态值. /** @Date : 2017-09-12 23:51:53 * @FileName: HDU 4778 状压DP 或 记忆化 好题.cpp * @Platform: Windows *…
HDOJ(HDU).3466 Dividing coins ( DP 01背包 无后效性的理解) 题意分析 要先排序,在做01背包,否则不满足无后效性,为什么呢? 等我理解了再补上. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 505 #define nn 505*100 using namespace std;…
HDOJ(HDU).2546 饭卡(DP 01背包) 题意分析 首先要对钱数小于5的时候特别处理,直接输出0.若钱数大于5,所有菜按价格排序,背包容量为钱数-5,对除去价格最贵的所有菜做01背包.因为这时候还剩下5块钱,直接买最贵的那个菜,就可以保证剩下来的钱数是最小的. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nma…
HDOJ(HDU).2602 Bone Collector (DP 01背包) 题意分析 01背包的裸题 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 1005 using namespace std; int v[nmax],w[nmax],dp[nmax]; int main() { //freopen("in…
HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2-15 */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define nmax 6000 #define min(a,b) (a<b?a:b…
HDOJ(HDU).1003 Max Sum (DP) 点我挑战题目 算法学习-–动态规划初探 题意分析 给出一段数字序列,求出最大连续子段和.典型的动态规划问题. 用数组a表示存储的数字序列,sum表示当前子段和,maxsum表示最大子段和.不妨设想:当sum为负数的时候: 1.当下一个数字a[i]为正数的时候,sum+a[i] < a[i],不如将sum归零重新计算 2.当下一个数字为负数的时候,sum+a[i]< 0 ,若再下一个数字还为负数,依旧可以得出和小于零--直到遇到一个正数,此…
Evacuation Plan Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 5665Accepted: 1481Special Judge 题目链接:http://poj.org/problem?id=2175 Description: The City has a number of municipal buildings and a number of fallout shelters that were build sp…
Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current number sequence includes the sub-sequence "49&…
Evacuation Plan Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 217564-bit integer IO format: %lld      Java class name: Main   The City has a number of municipal buildings and a number of fallout shelters th…
题目链接:PKU:HDU: PKU:http://poj.org/problem?id=3486 HDU:pid=1913" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=1913 Description Everybody is fond of computers, but buying a new one is always a money challenge. Fortunately, ther…
http://acm.hdu.edu.cn/showproblem.php?pid=1712 N门课M天复习,第i门课花费j天获得的效益是dp[i][j] 求最大效益 分组背包,同一门课不能选两次 三层循环 第一层:几个分组循环 第二层:总容量递减 第三层:抉择构成背包 dp[j]=max(dp[j],dp[j-c[k]]+w[k]);(其中c[k]为k物品的费用,w[k]为价值),由于递降枚举背包容量,max比较中的dp[j]是由上一组物品决策所得,在这里将被忽略.就算不忽略,在本组物品中dp…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3001 由于本题中一个点最多能够访问2次,由此可以联想到3进制; visited[i][j]表示在状态i下在点j已经做过的次数,dp[i][j]表示在状态i下到达点j走过的最小的路程,于是我们可以通过预处理得到visited[i][j]数组,然后就是一般的状态转移. /*******************************************************************…
1.HDU 2089  不要62    简单数位dp 2.总结:看了题解才敲出来的,还是好弱.. #include<iostream> #include<cstring> #include<cstdio> using namespace std; ][]; //dp[i][j]表示以j为首位符合条件的i位数的个数 void init() //预处理 { memset(dp,,sizeof(dp)); dp[][]=; ;i<;i++){ ;j<;j++){…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5898 题意:很明确,找出区间[l , r]中符合连续奇数为偶数,连续偶数为奇数的个数. 思路:dp[i][j][1]表示i位数j开头符合条件的数,dp[i][j][0]表示i位数j开头(之后)可能符合条件的数. #include<cstdio> #include<cstring> using namespace std; typedef long long ll; ll dp[22][…
L - 免费馅饼 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1176 Appoint description:  prayerhgq  (2015-07-28) System Crawler  (2015-11-21) Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4640 思路:f[i][j]表示一个人状态i下走到j的最小花费,dp[i][j]表示i个人在状态j下的最下花费.首先我们可以一遍bfs求出f[i][j],然后通过f[i][j]得到dp[1][i],最后就是更新dp[i][j]了. #include<iostream> #include<cstdio> #include<cstring> #include<algorit…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1074 题目大意:有N个作业(N<=15),每个作业需耗时,有一个截止期限.超期多少天就要扣多少分.问最少被扣多少分,且按字典序输出做作业顺序. 解题思路: 集合上的DP问题.也就是状态压缩DP. 用二进制位表示做作业的顺序.总bit=1<<15. 对于状态i,枚举当前的作业j,如果i&(1<<(j-1)),则表示当前状态含有作业j. t^=(1<<(j-1)…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5067 题目大意:蓝翔挖掘机挖石子.把地图上所有石子都运回起点,问最少耗时. 解题思路: 首先得YY出来. 最少耗时肯定是从起点出发,把所有石子点走一遍且只走一遍,把石子装在车上,然后最后回到起点. 由于石子堆最多也就10个.不难看出这就是个裸的TSP. 首先BFS计算出每个石子间的最短路.当时打BC的时候SB了,这题图没有障碍,直接根据坐标算就行了. 然后进行TSP就行了. 起点的石子无所谓.所以…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4856 题目大意:有一个迷宫.迷宫里有些隧道,每个隧道有起点和终点,在隧道里不耗时.出隧道就耗时,你的任务是访问完所有隧道且仅一次,求最短耗时. 解题思路: 暑假练习的时候.把英文读了N遍也没理解题意. 其实就是个最后不回到开头的TSP. 首先求BFS求两两隧道之间的最短路,注意BFS的起点是隧道i的终点,BFS的终点是隧道j的起点. 一定要特判一下两个隧道终点和起点是否一样,如果一样话dis=0,…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 15372    Accepted Submission(s): 5563 Problem Description The counter-terrorists f…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2089 不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 34901    Accepted Submission(s): 12664 Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoe…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4734 F(x) Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4389    Accepted Submission(s): 1614 Problem Description For a decimal number x with…
Rating Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4870 Description A little girl loves programming competition very much. Recently, she has found a new kind of programming competition named…
http://acm.hdu.edu.cn/showproblem.php?pid=4089 这道题中一共有两个循环: 1.事件1 如果一直落在Activation failed事件上,那么就会重新继续直到出现事件2,3,或4为止, 这样 进入事件2的概率是p2'=p2+p2*p1+p2*p1*p1........解这个无穷级数得到p2'=p2/(1-p1),同理,p3'=p3/(1-p1),p4=p4/(1-p1) 2.事件2 设dp[i][j]为队列长度为i,主角在j时满足条件的概率,则 当…