题意:给定一个有向图,你从1出发到n,走尽可能多的点,并且使总权值不大于t。 析:在比赛时,竟然看成有向图了,就想了好久,感觉dp,但是不会啊。。。如果是有向图就好做多了,枚举边,然后打印就好,dp[i][j] 表示, 经过 i 个结点,并且在 j的最小时间。 代码如下: ...
分类:
其他好文 时间:
2016-10-01 12:25:24
阅读次数:
226
一道图论题,DFS t了,BFS MLE了。看来最优解应该是DP没跑了。 下面尝试定义转移方程: dp[i][j]表示在经过了i个城市之后到达编号为j的城市所消耗的最小时间。 转移方程写得好,一切问题就变的简单了。反观这题,题中一共三个变量,经历城市数(希望最大化),消耗的时间(希望最小化),当前城 ...
分类:
其他好文 时间:
2016-10-01 12:25:07
阅读次数:
322
$dp$,拓扑排序。 记$dp[i][j]$表示走到节点$i$,走过了$j$个点的最小时间,然后就可以递推了。要注意的是节点$1$的入度一开始不一定等于$0$。 ...
分类:
其他好文 时间:
2016-10-01 10:33:39
阅读次数:
259
传送门 说实话,这是一道非常简单的DP题,简单到如果放到NOIp第二题可能都有些差强人意,然而我写崩了。 所以简单记录一下。 需要注意的是,这道题的DP应该是从$N$点开始,以1为边界,满足最短路的三角形性质即可转移。 1 //cf c 2 //by Cydiater 3 //2016.9.30 4 ...
分类:
其他好文 时间:
2016-10-01 06:09:50
阅读次数:
162
http://poj.org/problem?id=2488 A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41951 Accepted: 14274 Time Limit: 1000MS ...
分类:
其他好文 时间:
2016-09-29 00:47:15
阅读次数:
232
A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41936 Accepted: 14269 Description Background The knight is getting bored ...
分类:
其他好文 时间:
2016-09-28 02:04:02
阅读次数:
193
Stephen Smith's Blog All things Sage 300… The Road to TensorFlow – Part 7: Finally Some Code leave a comment » Introduction Well after a long journey ...
分类:
其他好文 时间:
2016-09-25 13:14:55
阅读次数:
524
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5881 Problem Description Tea is good.Tea is life.Tea is everything.The balance of tea is a journey of p ...
分类:
其他好文 时间:
2016-09-17 21:57:07
阅读次数:
191
A Sweet Journey Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 975 Accepted Submission(s): 504 P ...
分类:
其他好文 时间:
2016-09-14 00:12:53
阅读次数:
202
http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Problem Description 《Journey to the West》(also 《Monkey》) is one of the Four Great Clas ...
分类:
其他好文 时间:
2016-08-12 13:35:42
阅读次数:
367