Bessla Motors
Time limit3sMemory limit1024 MB
Find the travel destinations within R miles of at least K distinct charging stations on a weighted road graph, then print their count and list them in ascending order.
- Level
Medium6 of 10
- Topics
- Shortest path, Graph, Heap
- Solved
- No attempts yet
Problem
Farmer John wants to promote his line of Bessla electric tractors by showing off Bessla's network of charging stations. There are () points of interest labeled . The first () points are charging stations, and the rest are travel destinations. The points are connected by () bidirectional roads. The -th road connects distinct points and () and has length miles ().
A Bessla can travel up to miles () on a single charge, which lets it reach any destination within miles of a charging station. A destination is well-connected if it can be reached from at least () distinct charging stations. Find the set of well-connected travel destinations.
Input
The first line contains five space-separated integers , , , , and . Each of the following lines contains three space-separated integers , , and , where .
The charging stations are labeled . The remaining points are all travel destinations.
Output
First, print the number of well-connected travel destinations on a single line. Then print all of them in ascending order, one per line.