Answer the question
In order to leave comments, you need to log in
Mismatch in the question for the test task Yandex contest?
I decided to try this problem , but the task itself is not matched by condition, I can’t understand the logic of the calculation
No need to decide, just kick to the side - what I misunderstood
I decided to bypass the graph and on each branch I counted the cost as
But the result is not coincides with the result of the condition, I manually calculated the graphs - and I see that the input data in the task does not correspond to the output. Or I did not understand how to count the graph.cost = (s > 28 ? 28 : s) * l
Yandex is preparing to launch the Yandex.Market product delivery system using drones. Under current legislation, automated drones must only travel along predetermined airways.
You need to write a route module that, according to the route scheme (directed acyclic graph - DAG), returns all route options, sorted from the fastest to the longest. In the scheme, each next section brings you closer to the destination, there is no way back and there are no dead ends - each path leads to the destination.
The route consists of intersections/intersections and sections of the route between these intersections. Each section of the track has a different length (in meters) and a maximum speed (in m/s) allowed on that section. The drone also has a maximum speed (28 m/s), above which it is not capable of flying.
The route module must return a function that takes two parameters:
function findAllRoutes(segments, finishId) {
...
}
module.exports = findAllRoutes;
Пример входных данных:
const segments = [
{
f: ’1’, // from: id исходного узла
t: ’2’, // to: id конечного узла
l: 200, // length: длина отрезка
s: 30 // speed: ограничение скорости на участке
},
{f: ’2’, t: ’3’, l: 150, s: 30},
{f: ’2’, t: ’4’, l: 200, s: 25},
{f: ’2’, t: ’5’, l: 250, s: 30},
{f: ’3’, t: ’6’, l: 100, s: 25},
{f: ’4’, t: ’6’, l: 75, s: 15},
{f: ’5’, t: ’6’, l: 50, s: 20},
];
const finishId = ’6’;
const result = findAllRoutes(segments, finishId);
Пример выходных данных:
[
{
f: '1', // from: id исходного узла
t: '2', // to: id конечного узла
l: 200, // length: длина отрезка
s: 30 // speed: ограничение скорости на участке
}, 200 * 28 = 5600
{f: '2', t: '3', l: 150, s: 30}, 150 * 28 = 4200
{f: '2', t: '4', l: 200, s: 25}, 200 * 25 = 5000
{f: '2', t: '5', l: 250, s: 30}, 250 * 28 = 7000
{f: '3', t: '6', l: 100, s: 25}, 100 * 25 = 2500
{f: '4', t: '6', l: 75, s: 15}, 75 * 15 = 1125
{f: '5', t: '6', l: 50, s: 20}, 50 * 20 = 1000
];
[12300, 13600, 11725]
насколько я понимаю должно быть так
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question