#P14772. [ICPC 2024 Seoul R] Protecting Kingdom
[ICPC 2024 Seoul R] Protecting Kingdom
题目描述
In the kingdom of CPIC (Committee for Public Infrastructure Conservation), there are villages numbered from 1 to and connected by a network of roads forming a tree structure. Each road connects two villages and has a positive length. Specifically, the -th road connects village with village () and has a length of . Due to treacherous terrains and past incidents, some points along these roads are identified as hazardous.
On the -th road, there are hazardous points located at specific distances from village , satisfying . These distances are integers, indicating positions along the road.
The newly established CPIC Safety Committee aims to enhance traveler safety by deploying a protective measure. They can select any two points on the roads, including villages, and secure the shortest path between them. The path can cover all hazardous points located exactly on it, including its endpoints, and its length must not exceed a given length .
Given the road network, the positions of the hazardous points, and the maximum allowable path length , write a program to determine the maximum number of hazardous points that can be covered by optimally choosing the two points and securing the shortest path between them with length .
输入格式
Your program is to read from standard input. The input starts with a line containing two integers, and (, ), where is the number of villages and is the maximum allowable length of the secured path. In the following lines, the -th line, which provides information about the -th road, starts with three integers , , and (, , ), where is the village connected to village by the road, is the length of the road, and is the number of hazardous points on the road. If , the line is followed by integers (), representing the distances from village to each hazardous point along the road. The total number of hazardous points does not exceed .
输出格式
Your program is to write to standard output. Print exactly one line. The line should contain the maximum number of hazardous points that can be covered by a shortest path of length or less between any two points on the roads.
4 2
1 2 1 1
1 610 2 1 100
3 2001 0
2
2 2
1 2 1 1
1
8 6
1 2 1 1
1 3 2 1 2
2 1 0
3 4 1 2
2 3 1 1
1 4 1 3
3 4 1 1
4