#P1023. Problem 1. Bessla Motors

Problem 1. Bessla Motors

当前没有测试数据。

一、Problem Name

Bessla Motors

二、Problem Description

Note: The time limit for this problem is 3s, 1.5x the default. The memory limit for this problem is 512MB, twice the default.

Farmer John would like to promote his line of Bessla electric tractors by showcasing Bessla's network of charging stations. He has identified NN (2N51042\leq N\leq5\cdot10^4) points of interest labeled 1N1\cdots N, of which the first CC (1C<N1\leq C<N) are charging stations and the remainder are travel destinations. These points of interest are interconnected by MM (1M1051\leq M\leq10^5) bidirectional roads, the iith of which connects distinct points uiu_i and viv_i (1ui,viN1\leq u_i,v_i\leq N) and has length i\ell_i miles (1i1091\leq\ell_i\leq10^9).

A Bessla can travel up to 2R2R miles (1R1091\leq R\leq10^9) on a single charge, allowing it to reach any destination within RR miles of a charging station. A destination is deemed well-connected if it is reachable from at least KK (1K101\leq K\leq10) distinct charging stations. Your task is to assist Farmer John in identifying the set of well-connected travel destinations.

三、Input Format (input arrives from the terminal / stdin)

  1. The first line contains five space-separated integers NN, MM, CC, RR, and KK. Each of the following MM lines contains three space-separated integers uiu_i, viv_i, and i\ell_i such that uiviu_i\neq v_i.
  2. The charging stations are labeled 1,2,,C1,2,\cdots,C. The remaining points of interest are all travel destinations.

四、Output Format (print output to the终端 / stdout)

  1. First, output the number of well-connected travel destinations on a single line.
  2. Then, list all well-connected travel destinations in ascending order, each on a separate line.

五、Sample Input and Output

Sample Input 1

3 3 1 4 1
1 2 3
1 3 5
2 3 2

Sample Output 1

1
2

Explanation: We have one charging station at 1. From this charging station, we can reach point 2 (since it is distance 3 away from 1), but not point 3 (since it is distance 5 away from 1). Thus, only point 2 is well-connected.

Sample Input 2

4 3 2 101 2
1 2 1
2 3 100
1 4 10

Sample Output 2

2
3
4

Explanation: We have charging stations at 1 and 2, and both points 3 and 4 are within distance 101 of both 1 and 2. Thus, both points 3 and 4 are well-connected.

Sample Input 3

4 3 2 100 2
1 2 1
2 3 100
1 4 10

Sample Output 3

1
4

六、Scoring Rules

  1. Inputs 4 and 5: K=2K = 2 and N500N\leq500 and M1000M\leq1000.
  2. Inputs 6 and 7: K=2K = 2.
  3. Inputs 8 - 15: No additional constraints.

Problem credits: Alexander Wei.