Logo
(追記) (追記ここまで)

20679번 - JJ Rally 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB223327.273%

문제

The downtown is very busy this weekend. Javad and Jalal are each organizing a race, namely JavadRally and JalalRally. They have located the start and final intersections for each race and are now negotiating with the local police to finalize the route of each race. The police will close the intersections of each route on the race day, so there are no shared intersections in the routes. Moreover, since the race routes are closed by the local police on the race day which makes more traffic congestion in the downtown, each route must be the shortest path from the start to its final intersections. They have trouble figuring out the proper conflict-free routes, so they asked you for help to count the number of different ways to organize the races. Two races are different if the pair of their routes are different.

The map of the city is given as n intersections numbered 1 to n, and m roads connecting those intersections. Each road has a specified length. Moreover, for each rally, the start and the final intersections are given. You should calculate the number of the different conflict-free shortest path races.

입력

The first line of the input contains two integers n (4 ⩽ n ⩽ 24) and m (1 ⩽ m ⩽ n(n − 1)/2). The following m lines are the road descriptions. The i-th road has three integers: ui (1 ⩽ ui ⩽ n), vi (1 ⩽ vi ⩽ n), and wi (1 ⩽ wi ⩽ 1000) denoting its two end-vertices and its length. There are no self-loops and multiple edges in the given map and all roads are bidirectional. The last line contains 4 integer: s1, t1, s2, and t2 (1 ⩽ s1, t1, s2, t2 ⩽ n); the numbers of the start and the final intersections of Javad’s route and Jalal’s route, respectively. It is guaranteed that all these numbers are distinct. It is guaranteed that the given map is connected, i.e., there is a path between any two intersections.

출력

Print the number of different ways to organize both races.

제한

예제 입력 1

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

예제 출력 1

1

예제 입력 2

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

예제 출력 2

0

예제 입력 3

6 8
1 4 1
1 3 1
4 2 1
3 2 1
1 2 2
1 5 1
5 2 1
5 6 2
1 2 6 5

예제 출력 3

3

힌트

출처

ICPC > Regionals > Asia West Continent > Iran > Tehran Site 2020 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /