Surely You Congest
Time limit10sMemory limit256 MB
Route the most commuters to intersection 1 along shortest paths so no two enter the same road in the same direction at the same time.
- Level
Hard8 of 10
- Topics
- Graph, Shortest path
- Solved
- No attempts yet
Problem
You are designing a centralized traffic management system for smart cars. Using global information, you must tell morning commuters who drive from the suburbs to downtown how to reach the city center while avoiding traffic jams.
Commuters know the city and act in their own interest, so you cannot ask anyone to take a route that is slower than their fastest one: they would simply ignore such advice. You may only move a commuter onto a different route that is exactly as fast as their shortest one.
The road network consists of intersections connected by bidirectional roads, each with a travel time. Every commuter starts at some intersection (which may differ between commuters), and all of them finish downtown, at intersection . Congestion happens when two commuters begin travelling along the same road in the same direction at the same moment, and this must never happen. It is fine for two commuters to pass through the same intersection at the same time, or to use the same road at different times.
Every commuter leaves at exactly the same time, and none of them may take a suboptimal route. Determine the maximum number of commuters who can reach downtown with no congestion.
Input
The input consists of a single test case. The first line contains three integers , , and , where () is the number of intersections, () is the number of roads, and () is the number of commuters.
Each of the next lines contains three integers , , and describing one road, where and () are the two distinct intersections it connects, and () is the time to travel along it in either direction. Downtown (intersection ) is reachable from every intersection.
The last line contains integers, the starting intersections of the commuters.
Output
Print the maximum number of commuters who can reach downtown without congestion.