Problem Description My name is Hu Bayi, robing an ancient tomb in Tibet. The tomb consists of N rooms (numbered from 1 to N) which are connected by some roads (pass each road should cost some time). There is exactly one route between any two rooms, a…
K - The Ghost Blows Light Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4276 Appoint description:  System Crawler  (2015-10-20) Description My name is Hu Bayi, robing an ancient tomb in Tibet.…
题意:给出一棵n个节点的树,起点1,终点n,相连的两个节点之间有距离,每个节点有个价值,给出一个时间T.问从1到达n在给定时间T内取得的最大价值? 思路:先从1走到n,如果总的时间不够走完,直接退出,否则把时间扣掉,这些边权设置为0,然后做一遍树形DP #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> #include<iostream> int n,m;…
题意:给定一棵n个节点的树,起点是1,终点是n,每经过一条边需要消耗Ti天,每个点上有一定量的珠宝,要求必须在t天内到达终点才可以将珠宝带出去,问至多能带多少珠宝? 思路: 注意Ti可以为0,而且有可能t太小以至于不能到达n,则输出不可达.这样想会简单点,将"1->n"路径上的每条边断开,变成一片森林,而且路径上的这些点是根.我们需要计算每棵树在j天内最多能获得多少珠宝,这只需要一次DFS就可以完成了.然后除了森林中的根(即1->n路径上的点),其他都可以不用考虑了,按照&…
题目大意 给定一棵n个结点的树,每个结点上有一定数量的treasure,经过每条边需要花一定的时间,要求你从结点1出发,在不超过时间T的情况下,最多能够获得的treasure是多少,并且要求结束于结点n 题解 本题主要的困难是如何恰好结束于结点n. 先进行一次dfs求出从结点1到结点n的最短时间s(假设此条路径为a),如果s比T还大,不能走完,输出-1.否则的话继续处理,由于路径a是最短路径,因此肯定会经过此条路径,并且只会经过一次,其他的结点要么不经过,要么经过两次(因此时间花费是边权的两倍)…
题意 1. 给定一棵树, 树上节点有 value, 节点之间 travel 有 cost. 给定起始节点和最大 cost, 求解最大 value 思路 1. 寻找最短路径 a. 题目描述中有两句话, "There is exactly one route between any two rooms", "Each of the next N-1 lines contains three integers" 说明给出的结构是一棵树 b. 假如给定的时间小于起终节点间的…
The Ghost Blows Light Problem Description My name is Hu Bayi, robing an ancient tomb in Tibet. The tomb consists of N rooms (numbered from 1 to N) which are connected by some roads (pass each road should cost some time). There is exactly one route be…
The Ghost Blows Light Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 427664-bit integer IO format: %I64d      Java class name: Main     My name is Hu Bayi, robing an ancient tomb in Tibet. The tomb consists…
这个题目给定一棵树,以及树的每个树枝的苹果数量,要求在保留K个树枝的情况下最多能保留多少个苹果 一看就觉得是个树形DP,然后想出 dp[i][j]来表示第i个节点保留j个树枝的最大苹果数,但是在树形过程中,有点难表示转移 后来看了下大神的做法才知道其实可以用背包来模拟 树枝的去留,其实真的是个背包诶,每个子树枝就相当于物品,他占用了多少树枝量,带来多少的收益,就是用背包嘛,于是用树形DP+背包就可以做了 #include <iostream> #include <cstdio> #…
Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12770    Accepted Submission(s): 5142 Problem Description There is going to be a party to celebrate the 80-th Anniversary of the…