当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

BZOJ3889:[Usaco2015 Jan]Cow Routing

题目描述

Tired of the cold winter weather on her farm, Bessie the cow plans to fly to a warmer destination for vacation. Unfortunately, she discovers that only one airline, Air Bovinia, is willing to sell tickets to cows, and that these tickets are somewhat complicated in structure. Air Bovinia owns N planes (1 <= N <= 1000), each of which flies on a specific "route" consisting of two or more cities. For example, one plane might fly on a route that starts at city 1, then flies to city 5, then flies to city 2, and then finally flies to city 8. No city appears multiple times in a route. If Bessie chooses to utilize a route, she can board at any city along the route and then disembark at any city later along the route. She does not need to board at the first city or disembark at the last city. Each route has a certain cost, which Bessie must pay if she uses any part of the route, irrespective of the number of cities she visits along the route. If Bessie uses a route multiple times during her travel (that is, if she leaves the route and later comes back to use it from antoher city), she must pay for it each time it is used. Bessie would like to find the cheapest way to travel from her farm (in city A) to her tropical destination (city B). Please help her decide what is the minimum cost she must pay, and also the smallest number of individual flights she must use take to achieve this minimum cost.

第一行 s,t,m表示:起点,终点,m条航线。
然后m组,每组第一行len,n表示这条航线的代价, 
这类似于公交车,只要用了就花这些钱,但是用多少都这些钱。 
注意是单向边。
举例: 
2333 4 
3 2 1 4 
就是3->2、3->1、3->4、2->1、2->4、1->4都花2333元。
这个花销是第一键值。 
第二键值是经过几站。
比如3->2->1->4花费2333 
而如果有其它航线使得3->5->4花费1000+1333==2333的话, 
那么因为它经过了2站,所以更优。
然后求双键值最短路。 
输出这俩键值。
无解输出“-1 -1”。

输入解释
The first line of input contains A, B, and N, separated by spaces. The next 2N lines describe the available routes, in two lines per route. The first line contains the cost of using the route (an integer in the range 1..1,000,000,000), and the number of cities along the route (an integer in the range 1..100). The second line contains a list of the cities in order along the route. Each city is identified by an integer in the range 1..1000. Note that the cost of an itinerary can easily add up to more than can fit into a 32-bit integer, so you should probably use 64-bit integers (e.g., "long long" integers in C/C++).

输出解释
Output the minimum cost of an itinerary that Bessie can use to travel from city A to city B, as well as the minimum number of individual flights required to achieve this minimum cost. If there is no solution, output "-1 -1" (quotes for clarity) on a single line.

输入样例
3 4 3
3 5
1 2 3 4 5
2 3
3 5 4
1 2
1 5
输出样例
2 2
提示

BZPRO Powered by Remmina.
Github Repository
来自acmore.cc的附加信息
bzoj_id 3889
import_source_sha256 556efd42a3f652c14a2277c1af6643297ece27348ff39f8ef37861797a0af99f
bzoj_checker_pending False

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 3889

源链接: LOCAL-BZOJ3889

共提交 0 次

通过率 --%
时间上限 内存上限
10000 MS 128 MB