| { | |
| "text": "\n## Problem Description\nLittle Q is someone who loves to study, and he often goes to Wikipedia to learn about computer science.\n\nJust now, Little Q was studying a series of bitwise operators, and the bitwise XOR operator $\\oplus$ had a great impact on him. The bitwise XOR operator is a binary operator. It has the commutative property, meaning $i \\oplus j = j \\oplus i$.\n\nHe discovered that the bitwise XOR can be understood as follows: for the corresponding bits of the numbers involved in the operation, if the bits are the same, the result at that position will be $0$, otherwise it will be $1$. For example: $1(01) \\oplus 2(10) = 3(11)$.\n\nHe also realized that bitwise XOR can be understood as performing a bitwise addition without carry for each binary bit of the numbers involved in the operation. For example: $3(11) \\oplus 3(11) = 0(00)$.\n\nNow, Little Q has an undirected tree $T$ with $n$ nodes, numbered from $1$ to $n$, where the weight of node $i$ is $v_i$. \nThe value of a tree is the XOR sum of the weights of all its nodes. A connected subtree of tree $T$ is a connected subgraph of $T$, and it is also a tree.\nLittle Q wants to play a tree cutting game on this tree, where he will perform the following two operations repeatedly:\n- ``Change x y``, set the weight of node $x$ to $y$.\n- ``Query k``, query how many non-empty connected subtrees of $T$ have a value exactly equal to $k$.\n\nLittle Q loves mathematics and hopes you can quickly answer his questions. Can you write a program to help him?\n\n## Input Format\nThe first line contains two positive integers $n$, $m$, representing the number of nodes and the upper limit of weights. \nThe second line contains $n$ non-negative integers $v_1, v_2, \\dots, v_n$, representing the initial weights of each node. \nThe next $n-1$ lines each contain two positive integers $a_i$, $b_i$, representing an undirected edge connecting nodes $a_i$ and $b_i$. \nThe next line contains a positive integer $q$, representing the number of operations Little Q will perform. \nThe following $q$ lines describe each operation.\n\n## Output Format\nOutput several lines, each containing one integer, answering each query. Since the answer may be large, output the result modulo $10007$.\n\n## Sample Input:\n4 4\n2 0 1 3\n1 2\n1 3\n1 4\n12\nQuery 0\nQuery 1\nQuery 2\nQuery 3\nChange 1 0\nChange 2 1\nChange 3 3\nChange 4 1\nQuery 0\nQuery 1\nQuery 2\nQuery 3\n\n## Sample Output:\n3\n3\n2\n3\n2\n4\n2\n3\n\n## Data Range and Hints\nFor $100\\%$ of the data, $1 \\leq a_i, b_i, x \\leq n$, $0 \\leq v_i, y, k < m$, and there will be no more than $10000$ modification operations.\n" | |
| } |
Xet Storage Details
- Size:
- 2.67 kB
- Xet hash:
- 933769dd15777ac61e691d2cb04ea120f9230bd89db89106e43302508faf6c1d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.