Construction Project 2

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

요약
가중치 L인 간선 (u,v)를 추가했을 때 S에서 T까지 최단 거리가 K 이하가 되는 쌍의 개수를 센다.
난이도

보통10점 중 7점

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

문제

There are NN stations in JOI Kingdom, numbered from 11 to NN. There are MM train lines in JOI Kingdom, numbered from 11 to MM. The train line ii (1≤i≤M1 ≤ i ≤ M) connects station A_iA\_i and station B_iB\_i bi-directionally, and requires C_iC\_i minutes for travel.

You, a minister of JOI Kingdom, decided to construct a new train line as follows.

  • You choose integers uu and vv, which satisfy 1≤u<v≤N1 ≤ u < v ≤ N. You construct a new train line, which connects station uu and station vv bi-directionally, and requires LL minutes for travel. Note that you can choose 22 integers such that there already be a train line connecting station uu and station vv.

After you construct a new train line, the King of JOI Kingdom becomes happy if he can move from station SS to station TT within KK minutes by using some train lines. Note that transit times and waiting times for train lines are not considered.

There are N(N−1)2\frac{N(N-1)}{2} ways when you choose 22 integers uu and vv, and you want to know how many of these ways make the King happy.

Write a program which, given information of stations, the train lines, and the King’s request, calculates number of ways to choose 22 integers that make the King happy.

입력

Read the following data from the standard input.

NN MM

SS TT LL KK

A_1A\_1 B_1B\_1 C_1C\_1

A_2A\_2 B_2B\_2 C_2C\_2

⋮\vdots

A_MA\_M B_MB\_M C_MC\_M

출력

Write one line to the standard output. The output should contain number of ways to choose 22 integers that make the King happy.

제한

  • 2≤N≤200,0002 ≤ N ≤ 200\\, 000.
  • 1≤M≤200,0001 ≤ M ≤ 200\\, 000.
  • 1≤S<T≤N1 ≤ S < T ≤ N.
  • 1≤L≤1091 ≤ L ≤ 10^9.
  • 1≤K≤10151 ≤ K ≤ 10^{15}.
  • 1≤A_i<B_i≤N1 ≤ A\_i < B\_i ≤ N (1≤i≤M1 ≤ i ≤ M).
  • (A_i,B_i)≠(A_j,B_j)(A\_i , B\_i) \ne (A\_j , B\_j) (1≤i<j≤M1 ≤ i < j ≤ M).
  • 1≤C_i≤1091 ≤ C\_i ≤ 10^9 (1≤i≤M1 ≤ i ≤ M).
  • Given values are all integers.

예제4

  1. 예제 1

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

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

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

    입력
    18 21
    4 8 678730772 3000000062
    5 13 805281073
    8 17 80983648
    3 8 996533440
    10 16 514277428
    2 5 57914340
    6 11 966149890
    8 12 532734310
    2 9 188599710
    2 3 966306014
    12 16 656457780
    16 18 662633078
    1 15 698078877
    2 8 665665772
    2 6 652261981
    14 15 712798281
    7 13 571169114
    13 14 860543313
    6 7 454251187
    9 14 293590683
    6 14 959532841
    3 11 591245645
    
    예상 출력
    16