#P10662. BZOJ4202 石子游戏
BZOJ4202 石子游戏
Problem Description
The Stone Game is a type of game that many people enjoy. This kind of game is usually related to moving stones and choosing whether to take them, and it often brings a lot of fun.
There is a type of stone game on a tree with the following rules: on a rooted tree, each node has a certain number of stones. Two players take turns to play. Each turn, a player may move at most stones to the parent of a node, and in one turn they can only move stones from one node. Obviously, the root has no parent, so once a stone is moved to the root, it can no longer be moved. The question is: when playing this game on the subtree rooted at some node, does the first player have a winning strategy.
To make the game harder, we make some small changes. Now, this tree may grow new nodes. Also, the number of stones on each node may change. Please answer: when playing this stone game on the subtree rooted at some node, does the first player have a winning strategy. This problem requires mandatory online processing.
Input Format
The first line contains two integers , meaning that initially there are nodes, and each move can move at most stones.
The second line contains positive integers , representing the initial number of stones, where node is the root.
The next lines each contain two integers , indicating that there is an edge between and .
The next line contains a positive integer , denoting the number of operations.
The next lines each describe one operation. The first number of each line is the operation type:
- If it is , it is followed by an integer , meaning to ask whether the first player must win when playing the game in the subtree of .
- If it is , it is followed by two integers , meaning to modify the number of stones at node to .
- If it is , it is followed by three integers , meaning to add a child to node , whose initial number of stones is .
Output Format
For each query, output Yes if the first player must win; otherwise output No.
Note: The testdata is processed with mandatory online handling. For each operation, except for the type number, all other numbers need to be XORed with the number of previous answers that are Yes.
2 1000
0 0
1 2
1
1 1
No
Hint
For of the data, . Also, it is guaranteed that at any time, the number of nodes in the tree and the node indices will not exceed . All other values are within the range of int.
Translated by ChatGPT 5