3890: [Usaco2015 Jan]Meeting Time( dp )
简单的拓扑图dp..
A(i, j), B(i, j) 表示从点 i 长度为 j 的两种路径是否存在. 用bitset就行了
时间复杂度O(m)
----------------------------------------------------------------
----------------------------------------------------------------
3890: [Usaco2015 Jan]Meeting Time
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 95 Solved: 65
[Submit][Status][Discuss]
Description
Bessie and her sister Elsie want to travel from the barn to their favorite field, such that they leave at exactly the same time from the barn, and also arrive at exactly the same time at their favorite field. The farm is a collection of N fields (1 <= N <= 100) numbered 1..N, where field 1 contains the barn and field N is the favorite field. The farm is built on the side of a hill, with field X being higher in elevation than field Y if X < Y. An assortment of M paths connect pairs of fields. However, since each path is rather steep, it can only be followed in a downhill direction. For example, a path connecting field 5 with field 8 could be followed in the 5 -> 8 direction but not the other way, since this would be uphill. Each pair of fields is connected by at most one path, so M <= N(N-1)/2. It might take Bessie and Elsie different amounts of time to follow a path; for example, Bessie might take 10 units of time, and Elsie 20. Moreover, Bessie and Elsie only consume time when traveling on paths between fields -- since they are in a hurry, they always travel through a field in essentially zero time, never waiting around anywhere. Please help determine the shortest amount of time Bessie and Elsie must take in order to reach their favorite field at exactly the same moment.
给出一个n个点m条边的有向无环图,每条边两个边权。
n<=100,没有重边。
然后要求两条长度相同且尽量短的路径,
路径1采用第一种边权,路径2采用第二种边权。
没有则输出”IMPOSSIBLE”
Input
Output
Sample Input
1 3 1 2
1 2 1 2
2 3 1 2
Sample Output
SOLUTION NOTES:
Bessie is twice as fast as Elsie on each path, but if Bessie takes the
path 1->2->3 and Elsie takes the path 1->3 they will arrive at the
same time.
HINT
Source
3890: [Usaco2015 Jan]Meeting Time( dp )的更多相关文章
- BZOJ 3890 [Usaco2015 Jan]Meeting Time:拓扑图dp
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3890 题意: 给你一个有向图,n个点(n <= 100),m条边. 且所有的边都是从 ...
- bzoj3890 [Usaco2015 Jan]Meeting Time
Description Bessie and her sister Elsie want to travel from the barn to their favorite field, such t ...
- BZOJ3887 [Usaco2015 Jan] Grass Cownoisseur 【tarjan】【DP】*
BZOJ3887 [Usaco2015 Jan] Grass Cownoisseur Description In an effort to better manage the grazing pat ...
- BZOJ_3887_[Usaco2015 Jan]Grass Cownoisseur_强连通分量+拓扑排序+DP
BZOJ_3887_[Usaco2015 Jan]Grass Cownoisseur_强连通分量+拓扑排序+DP Description In an effort to better manage t ...
- [bzoj3887][Usaco2015 Jan]Grass Cownoisseur_trajan_拓扑排序_拓扑序dp
[Usaco2015 Jan]Grass Cownoisseur 题目大意:给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过?(一个点在 ...
- [补档][Usaco2015 Jan]Grass Cownoisseur
[Usaco2015 Jan]Grass Cownoisseur 题目 给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过? (一个点在路 ...
- bzoj3887: [Usaco2015 Jan]Grass Cownoisseur
题意: 给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过?(一个点在路径中无论出现多少正整数次对答案的贡献均为1) =>有向图我们 ...
- 【bzoj3886】[Usaco2015 Jan]Moovie Mooving 状态压缩dp+二分
题目描述 Bessie is out at the movies. Being mischievous as always, she has decided to hide from Farmer J ...
- BZOJ 1677: [Usaco2005 Jan]Sumsets 求和( dp )
完全背包.. --------------------------------------------------------------------------------------- #incl ...
随机推荐
- 数据层使用DBHelper.dll来减少工作量
目前在需求确定了以后进行开发的步骤一般是这样的:建立数据表,建立model,构建数据操作层,最后在页面中进行调用.关于数据操作层,因为大量的操作都集中在增加.更新.删除等简易操作,而我之前的写法是每次 ...
- 如何查看.Net源代码vs版本号以及C#项目中各文件的含义
查看.Net源代码vs版本号以及C#项目中各文件的含义 用记事本打开vs项目的.sln文件. 第2行就是这个源代码包的开发软件vs版本号了 注意了,如果是vs2003的sln文件通常没有这行,可以判断 ...
- PHP学习笔记10-图片加水印
先找好一张图片,更名为face.jpeg,创建watermark.php: <?php /** * Created by PhpStorm. * User: Administrator * Da ...
- ie条件注释还能这样写
通过条件注释给html开始标签定义不同的class, 来区分不同版本的IE,可以在样式表中避免 样式属性hack (如 _margin-top, *float:none ) 注意: IE10+不支持条 ...
- 在非MFC程序中使用调试宏 ASSERT(),VERIFY()和 TRACE()
游戏制作已经开始采用C++了,却鲜有人选择使用MFC.但笔者觉得的 ASSERT(),VERIFY()和 TRACE()这几个宏很好用.所以就想自己写一个版本来适应Windows平台下不同的工程类型. ...
- Friendship of Frog(水题)
Friendship of Frog Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- hadoop、spark/storm等大数据相关视频资料汇总下载
小弟不才,工作中也用到了大数据的相关东西.一開始接触的时候,是通过买来的教学视频入的门.这两天整理了一下自己的视频资料.供各位进行下载. 文档截图:
- 暂时和永久改动oracle sysdate的默认输出格式
1.当前会话有效 alter session set NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS'; 2.永久生效 sys用户登入后运行例如以下命令 然后重新启动数据 ...
- c# datagridviewcomboboxcell值无效的解决办法
一直认为是数据库存储的数据和datagridviewcomboboxcell对不上导致,今天碰到两者对应上了,预览的时候还是提示错误, 查看了下网上其他大神的解决方法,是数据库字段类型有误,查看了下, ...
- html里面自定义弹出窗口
网页上默认的提示框或对话框一般比较丑,可以利用div遮盖层来自定义对话框 1.定义一个按钮或者链接(项目里面是通过点击一个图片) <img src="images/zz.gif&quo ...