A10620 | Xor-matic Number of the Graph
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given an undirected graph, constisting of $n$ vertices and $m$ edges. Each edge of the graph has some non-negative integer written on it.
Let's call a triple $(u,v,s)$ interesting, if $1<=u<v<=n$ and there is a path (possibly non-simple, i.e. it can visit the same vertices and edges multiple times) between vertices $u$ and $v$ such that xor of all numbers written on the edges of this path is equal to $s$ . When we compute the value s for some path, each edge is counted in xor as many times, as it appear on this path. It's not hard to prove that there are finite number of such triples.
Calculate the sum over modulo $10^{9}+7$ of the values of $s$ over all interesting triples.
Let's call a triple $(u,v,s)$ interesting, if $1<=u<v<=n$ and there is a path (possibly non-simple, i.e. it can visit the same vertices and edges multiple times) between vertices $u$ and $v$ such that xor of all numbers written on the edges of this path is equal to $s$ . When we compute the value s for some path, each edge is counted in xor as many times, as it appear on this path. It's not hard to prove that there are finite number of such triples.
Calculate the sum over modulo $10^{9}+7$ of the values of $s$ over all interesting triples.
输入格式
The first line of the input contains two integers $n$ and $m$ ( $1<=n<=100000$ , $0<=m<=200000$ ) — numbers of vertices and edges in the given graph.
The follow $m$ lines contain three integers $u_{i}$ , $v_{i}$ and $t_{i}$ ( $1<=u_{i},v_{i}<=n$ , $0<=t_{i}<=10^{18}$ , $u_{i}≠v_{i}$ ) — vertices connected by the edge and integer written on it. It is guaranteed that graph doesn't contain self-loops and multiple edges.
The follow $m$ lines contain three integers $u_{i}$ , $v_{i}$ and $t_{i}$ ( $1<=u_{i},v_{i}<=n$ , $0<=t_{i}<=10^{18}$ , $u_{i}≠v_{i}$ ) — vertices connected by the edge and integer written on it. It is guaranteed that graph doesn't contain self-loops and multiple edges.
输出格式
Print the single integer, equal to the described sum over modulo $10^{9}+7$ .
输入输出样例
输入 #1
4 4 1 2 1 1 3 2 2 3 3 3 4 1
输出 #1
12
输入 #2
4 4 1 2 1 2 3 2 3 4 4 4 1 8
输出 #2
90
输入 #3
8 6 1 2 2 2 3 1 2 4 4 4 5 5 4 6 3 7 8 5
输出 #3
62
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$ .
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted