21751_Invasion

2022-5-16 18:20| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505816066599-Problem List-采集的数据-后羿采集器.html

Pro.ID

21751

Title

Invasion

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21751

AC

18

Submit

160

Ratio

11.25%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Alien invasion began, and scary man-eating aliens are establishing their bases all over the country. You are only safe on the places that are sufficiently far away from all current alien bases. You need to quickly write a program to help you determine where to move.

    输入

    The input contains several instances, each of them consisting of several lines. The first line of each instance contains integers N (1 ≤ N ≤ 10000), M (0 ≤ M ≤ 100000), A (0 ≤ AN) and K (1 ≤ K ≤ 100) separated by spaces, giving the number of towns in the country, the number of roads between them, the number of bases that the aliens are going to build, and the minimum safe distance from alien bases, respectively. The towns are assigned numbers 1, ... , N.

    The following M lines describe the roads; each of them contains integers T1, T2 (1 ≤ T1 < T2N) and D (1 ≤ D ≤ 100) separated by spaces, where D is the length of the road between towns T1 and T2. There is at most one direct road between any two towns. All roads can be used in both directions.

    The following A lines describe the positions of alien bases; the i-th of them contains the number Bi (1 ≤ BiN) of the town where the aliens build their i-th base.

    Each instance is followed by one empty line. The empty line after the last instance is followed by a line containing four zeros.

    输出

    Description

    Alien invasion began, and scary man-eating aliens are establishing their bases all over the country. You are only safe on the places that are sufficiently far away from all current alien bases. You need to quickly write a program to help you determine where to move.

    Input

    The input contains several instances, each of them consisting of several lines. The first line of each instance contains integers N (1 ≤ N ≤ 10000), M (0 ≤ M ≤ 100000), A (0 ≤ AN) and K (1 ≤ K ≤ 100) separated by spaces, giving the number of towns in the country, the number of roads between them, the number of bases that the aliens are going to build, and the minimum safe distance from alien bases, respectively. The towns are assigned numbers 1, ... , N.

    The following M lines describe the roads; each of them contains integers T1, T2 (1 ≤ T1 < T2N) and D (1 ≤ D ≤ 100) separated by spaces, where D is the length of the road between towns T1 and T2. There is at most one direct road between any two towns. All roads can be used in both directions.

    The following A lines describe the positions of alien bases; the i-th of them contains the number Bi (1 ≤ BiN) of the town where the aliens build their i-th base.

    Each instance is followed by one empty line. The empty line after the last instance is followed by a line containing four zeros.

    Output

    The output for each input instance consists of A lines. On i-th line, write the number of towns that are safe after the aliens build their i-th base. The town is safe if its distance from any of the towns B1, B2, ... , Bi is at least K.

    Print one empty line after each instance.

    Sample Input

    7 6 3 3
    1 2 1
    1 3 1
    2 5 1
    3 6 1
    1 4 1
    4 7 2
    2
    1
    4

    1 0 1 1
    1

    0 0 0 0

    Sample Output

    2
    1
    0

    0

    Source

    样例输入

    7 6 3 3
    1 2 1
    1 3 1
    2 5 1
    3 6 1
    1 4 1
    4 7 2
    2
    1
    4

    1 0 1 1
    1

    0 0 0 0

    样例输出

    2
    1
    0

    0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部