2019 icpc西安邀请赛 J题 And And And

给定一棵有根树,计算所有路径上边权重的异或和为0的子路径数量的总和,模1000000007。采用深度优先搜索策略进行解决。
摘要由CSDN通过智能技术生成

A tree is a connected graph without cycles. You are given a rooted tree with nn nodes, labeled from 1 to n1ton. The tree is rooted at node 11. The parent of the ii-th node is f_{a_i}fai​​. The edge weight between the ii-th node and f_{a_i}fai​​ is w_iwi​

  • E(u, v)E(u,v) is a set of all the nodes through a path which is from uu to vv, including uu and vv. For example,

E(5,3) = \{5, 2, 1, 3\}, E(4,6) = \{4, 3, 6\}, E(2,5) = \{2,5\}E(5,3)={5,2,1,3},E(4,6)={4,3,6},E(2,5)={2,5}

  • X(u, v)X(u,v) represents the XOR of all edge weights on the path from uu to vv

For example, in the case given above,

X(1,5) = 1X(1,5)=1 ⁡xorxor 1=01=0,X(4,6) = 1X(4,6)=1 ⁡xorxor 3=23=2,X(2,5

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值