跳到正文

题解

「Cfz Round 4」Ad-hoc Master Tutorial

MatrixGroup约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 2 分钟
获赞
5
题目
P10857

版本

  1. v1当前

Let’s find one possible rr first. Since the given information of the nodes are symmetric, one should focus on the XOR sum of all the fu,kf_{u,k} for a specific kk. One can easily verify that, for k≥2k\ge 2, the value is exactly fr,k−1f_{r,k-1}. Additionally, since the only given information of a node is its ff value, one can arbitrarily choose one rr whose ff value matches the desired value.

It can be easily verified that the XOR sum of all fr,kf_{r,k} is the XOR sum of the value of all nodes except rr. Therefore, to find ww, one only needs to find the XOR sum of the value of all nodes. Using the given ff, one can easily evaluate the XOR sum of the value of the nodes whose distance from one specific node is odd. If one colors the tree in two colors by the parities of the nodes’ depths, or their distances from the root, then two nodes’ distance is odd if and only if they are of different colors. Therefore, the value described above is the same for nodes of the same color, and the XOR sum of the value of two different colored nodes is exactly what is needed. Find all the distint values, and the needed value if 00 is there is only one distinct value, and their XOR sum if there are two distinct values.

原文