|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|3 초||512 MB||13||12||11||91.667%|
Taking holidays unfortunately has a carbon footprint. The CO2-cost of a kilometer traveled depends on the mode of transportation. For instance, train travel is less costly than bus travel, which is itself less costly than car travel.
Your objective is to plan a holiday trip from your house, given by 2D coordinates (xs, ys), to your travel destination, given by (xd, yd). Being aware of the environmental impact of travel, you want to minimize the CO2-cost of your holiday, but you still want to keep the total number of kilometers traveled within a given budget B.
To aid you in planning, you have access to a map of N stations, possibly linked by T different modes of transportation (airplane, train, etc.) numbered 1, . . . , T. Each mode has a CO2-cost per distance unit C1, . . . , CT. You can travel by car from your home to the destination, from your home to any station, and from any station to the destination point, at a cost C0 per distance unit. C0 is always greater than any of C1, . . . , CT.
Each of the N stations has coordinates (xi, yi) for i = 0, . . . , N − 1. Each station may be connected to some other stations via one or several of the T modes. Each connection works both ways, so only one direction has to be listed. There can be multiple modes of transportation available between two stations. You can only travel between two stations via their connections using the available transportation modes (car travel is not allowed between stations).
The distance between two points a and b is the 2D distance between (xa, ya) and (xb, yb), rounded to the nearest integer above:
dist(a, b) = ⌈√((xa - xb)2 + (ya - yb)2)⌉,
and the CO2-cost of travel between a and b, using transport mode i is:
cost(a, b, i) = Ci × dist(a, b).
Given two source–destination coordinates, a budget B expressed in distance units, a list of transportation modes and their respective CO2-costs, and the station network, your task is to compute the minimal CO2-cost possible while traveling at most B kilometers.
The input consists of the following lines:
The output should contain a single line with a single integer representing the minimal feasible CO2-cost or −1 if no feasible cost is found within the kilometer budget.
All inputs are integers. All coordinates are in [0, 100] × [0, 100].
1 1 10 2 12 100 2 10 50 3 2 3 2 1 1 2 2 5 5 1 2 1 9 3 0
The results corresponds to the CO2-cost of the following route:
This route is valid because the total distance traveled is 3 + 7 + 2 = 12, within the allowed budget of 12.