题目描述
Problem Description
There are $ N $ stations and $ M $ tracks connecting them.
Track $ i $ directly connects station $ A_i $ and station $ B_i $, with a route length of $ L_i $ meters.
Find how many tuples $ (a,b,c) $ satisfy $a < c, a \neq b, b \neq c$, where there exist tracks directly connecting station $ a $ and station $ b $, and station $ b $ and station $ c $, and the sum of the two route lengths is $ 2540 $ meters.
It is guaranteed that there are no tracks connecting the same station or stations not connected by any track, but not all stations are necessarily connected.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ A_1 $ $ B_1 $ $ L_1 $ $ : $ $ A_M $ $ B_M $ $ L_M $
Output Format
Output $ x $ when there are $ x $ tuples $ (a,b,c) $ that satisfy the conditions.
Sample Input and Output
Sample Input #1
4 3
1 2 1420
2 3 1120
3 4 1420
Sample Output #1
2
Sample Input #2
4 2
1 2 1920
3 4 1125
Sample Output #2
0
Notes/Hints
Constraints
- $2 \leq N \leq 10^5$
- $1 \leq M \leq 10^5$
- $1 \leq A_i < B_i \leq N$
- $(A_i, B_i) \neq (A_j, B_j) (i \neq j)$
- $1000 \leq L_i \leq 2000$
- All inputs are integers
- There are no stations not connected by any track
Sample Explanation 1
$ (1,2,3), (2,3,4) $ satisfy the conditions.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分