CF724G Xor-matic Number of the Graph
题目描述
给你一个无向图,有n个顶点和m条边,每条边上都有一个非负权值。
我们称一个三元组 $(u,v,s)$ 是有趣的,当且仅当对于 $1 \le u < v \le n$ 且有一条从 $u$ 到 $v$ 的路径(可以经过相同的点和边多次),其路径上的权值异或和为 $s$。对于一条路径,如果一条边经过了多次,则计算异或和时也应计算多次。不难证明,这样的三元组是有限的。
计算所有有趣的三元组中 $s$ 的和对于 $10^9+7$ 的模数
输入格式
第一行包括两个整数 $n,m,(n\in [1,10^5],m\in[0,2*10^5]$ ——图中点数与边数
接下来的 $m$ 行每行包括3个整数 $u_i,v_i,t_i(u_i,v_i\in [1,n],t_i\in [0,10^{18}],u_i\not = v_i)$ ——边的两端点序号与边的权值
图中无自环与重边
输出格式
输出一个整数,即题目中的答案对于 $10^9+7$ 的mod值
感谢@Dimitry_L 提供的翻译
说明/提示
In the first example the are $ 6 $ interesting triples:
1. $ (1,2,1) $
2. $ (1,3,2) $
3. $ (1,4,3) $
4. $ (2,3,3) $
5. $ (2,4,2) $
6. $ (3,4,1) $
The sum is equal to $ 1+2+3+3+2+1=12 $ .In the second example the are $ 12 $ interesting triples:
1. $ (1,2,1) $
2. $ (2,3,2) $
3. $ (1,3,3) $
4. $ (3,4,4) $
5. $ (2,4,6) $
6. $ (1,4,7) $
7. $ (1,4,8) $
8. $ (2,4,9) $
9. $ (3,4,11) $
10. $ (1,3,12) $
11. $ (2,3,13) $
12. $ (1,2,14) $
The sum is equal to $ 1+2+3+4+6+7+8+9+11+12+13+14=90 $ .