Bessla Motors

시간 제한3초메모리 제한1024 MB

요약
가중 무방향 그래프에서 처음 C개 충전소 중 K개 이상으로부터 거리 R 이내에 있는 여행지를 세고 오름차순으로 출력한다.
난이도

보통10점 중 7점

유형
최단 경로, 그래프, 힙, 정렬
정답자
아직 제출이 없습니다

문제

Farmer John would like to promote his line of Bessla electric tractors by showcasing Bessla's network of charging stations. He has identified NN (2≤N≤5⋅1042\le N\le 5\cdot 10^4) points of interest labeled 1…N1\dots N, of which the first CC (1≤C<N1\le C < N) are charging stations and the remainder are travel destinations. These points of interest are interconnected by MM (1≤M≤1051\le M\le 10^5) bidirectional roads, the ii-th of which connects distinct points u_iu\_i and v_iv\_i (1≤u_i,v_i≤N1\le u\_i, v\_i\le N) and has length ℓ_i\ell\_i miles (1≤ℓ_i≤1091\le\ell\_i\le 10^9).

A Bessla can travel up to 2R2R miles (1≤R≤1091\le R\le 10^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 (1≤K≤101\le K\le 10) distinct charging stations. Your task is to assist Farmer John in identifying the set of well-connected travel destinations.

입력

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 u_iu\_i, v_iv\_i, and ℓ_i\ell\_i such that u_i≠v_iu\_i\neq v\_i.

The charging stations are labeled 1,2,…,C1, 2, \ldots, C. The remaining points of interest are all travel destinations.

출력

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

예제3

  1. 예제 1

    입력
    3 3 1 4 1
    1 2 3
    1 3 5
    2 3 2
    
    예상 출력
    1
    2
    
  2. 예제 2

    입력
    4 3 2 101 2
    1 2 1
    2 3 100
    1 4 10
    
    예상 출력
    2
    3
    4
    
  3. 예제 3

    입력
    4 3 2 100 2
    1 2 1
    2 3 100
    1 4 10
    
    예상 출력
    1
    4