CSU 1333 Funny Car Racing (最短路)】的更多相关文章

题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333 解题报告:一个图里面有n个点和m条单向边,注意是单向边,然后每条路开a秒关闭b秒,问从s点到t点的最短时间.一个简单的最短路稍微变了一下. 卡了很久就因为没看到边是单向边,无语.可以用队列优化. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm>…
最短路问题稍微复杂了一点,松弛的时候多判断一些条件就可以了.第一次用SPFA写最短路. #include<cstdio> #include<cmath> #include<cstring> #include<vector> #include<queue> #include<algorithm> using namespace std; ; vector<int> cost[maxn][maxn]; vector<in…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333 这题多了一个限制条件是每一条路都会规律的开放a时间关闭b时间,车子必须在开放的时候进入,在关闭之前出来,那么在加边的时候只要权值>开放时间的就不用加进去了. 还有一个问题是重边,那么用邻接表存储就好,并且这题不用spfa就超时,至于判断到达某一个点的时间,只要比较dist[x]%(temp.a+temp.b)的数即可. 算出来之后a需要判断是否还能够在剩余时间通过这个路口,不然就需要等待.…
There is a funny car racing in a city with n junctions and m directed roads. The funny part is: each road is open and closed periodically. Each road is associate with two integers (a, b), that means the road will be open for a seconds, then closed fo…
描述 There is a funny car racing in a city with n junctions and m directed roads. The funny part is: each road is open and closed periodically. Each road is associate with two integers (a, b), that means the road will be open for a seconds, then closed…
Description 众所周知,CSU(California State)University) 的上课地点距离学生公寓很远,对于爱睡懒觉的小Z来说,每天去上课就成了一件非常头疼的事,如果有早课的话更是如此.为了能让自己多睡一会,同时不至于上课迟到,小Z决定规划一条去新校的路线. 去新校的路上有很多条双向道路,每条道路连接了两个路口,且直接连接两个路口的道路只有一条,不存在一条道路的两端为同一个路口,每条道路都有一定的距离.同时道路两侧商铺众多,在提供了美食的同时也造成了一定程度的拥堵,在小Z…
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1806 题目大意: N个点M条有向边,给一个时间T(2≤n≤10,1≤m≤n(n-1),1≤T≤104),每条边的花费是关于t的一次函数Ci*t+Di,而你能选择出发时间t(0<=t<=T),走过边视为瞬间到达,不影响t,f(t)表示在时间t开始从1出发到n的最小花费,求 题目思路: [最短路][数学] 这题首先有个积分符号被吓到了,但是其实不难,N才10. 很容易想到枚举t,求1到…
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1808 题目大意: N个点M条无向边(N,M<=105),每条边属于某一条地铁Ci(Ci<=109),每条边有一个耗时,如果乘Ci号线地铁到达一个节点换乘Cj号线地铁离开,还需要花费|Ci-Cj|时间. 求1到n的最小花费时间. 题目思路: [最短路][STL] d[u][Ci]表示从1到u,最后一条地铁是Ci号线的最小耗时.按照边做,每条边枚举上一个是从哪一条地铁坐过来的,更新答案…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1808 Time limit: 5000 ms Memory limit: 131072 kB Bobo 居住在大城市 ICPCCamp. ICPCCamp 有 n 个地铁站,用 1,2,…,n 编号. m 段双向的地铁线路连接 n 个地铁站,其中第 i 段地铁属于 c i 号线,位于站 a i,b i 之间,往返均需要花费 t i 分钟(即从 a i 到 b i需要 t i 分钟,…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1659 题意是找一个图的中心,图的中心定义是某一个点到其他点的最大距离最小,如果有多个排序输出. 注意这里大到其他点的距离是找一个最短的距离,那么就转化成了最短路的问题,求出每个点与其它点的最大距离, 保存并且求出最大距离中的最小距离,然后判断有几个点满足条件输出即可. #include <iostream> #include <cstdio> #include <cmath&…