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 ...
随机推荐
- Introduction to Guid ( globally unique identifier )
什么是 GUID? 全球唯一标识符 (GUID) 是一个字母数字标识符,用于指示产品的唯一性安装. 在许多流行软件应用程序(例如 Web 浏览器和媒体播放器)中,都使用 GUID. GUID 的格式为 ...
- C语言选择法排序
#include <stdio.h> int main() { int i, j, p, n, q; ] = {, , , , }; //对无序数组进行排序 ; i<; i++) { ...
- 深入浅出—JAVA(8)
8.接口与抽象类 不是抽象的类就被称为具体类 不同继承树的类也可以实现相同的接口,类可以实现多个接口.
- 第二节 EAN 8 码 / EAN 13 码
EAN码的全名为欧洲商品条码(European Article Number),源於西元1977年,由欧洲十二个工业国家所共同发展出来的一种条码.目前已成为一种国际性的条码系统.EAN条码系统的管理是 ...
- QStringLiteral的两篇外文解释(编译期转换成QString)
http://blog.qt.io/blog/2014/06/13/qt-weekly-13-qstringliteral/ https://woboq.com/blog/qstringliteral ...
- hibernate 数据关联一对多 3.1
一对多,多对一 (在多的一端存放一的外键) 但是在实体类中不需要创建这个外键 // 在一的一方创建Set集合 public class User { private Integer id; priva ...
- 我在北京找工作(二):java实现算法<1> 冒泡排序+直接选择排序
工作.工作.找工作.经过1个多星期的思想斗争还是决定了找JAVA方面的工作,因为好像能比PHP的工资高点.呵呵 :-) (其实我这是笑脸,什么QQ输入法,模拟表情都没有,忒不人性化了.) 言归正传, ...
- cocos2dx进阶学习之CCScene
继承关系 CCScene -> CCNode -> CCObject CCScene抽象了一个场景的概念,类似舞台的一幕 函数 static CCScene *create(void); ...
- (step5.1.3)hdu 1213( How Many Tables——1213)
题目大意:输入两个整数n,m.分别表示点数.对点的操作的次数.在接下来的m行中,每行有两个整数a,b.表示a和b是好朋友.(不是好朋友的不能坐在同一个桌子上) .求需要多少张桌子 解题思路:并查集 1 ...
- iOS之UITableViewCell左右滑动效果
首先在 UITableViewCell.h 中声明一个代理 @protocol UITableViewCellSlideDelegate <UITableViewDelegate> @op ...