#P10990. [蓝桥杯 2023 国 Python A] 彩色二叉树
[蓝桥杯 2023 国 Python A] 彩色二叉树
Background
It is recommended to use PyPy3 to submit this problem.
Problem Description
Given a complete binary tree with nodes. The figure below shows a complete binary tree with nodes.
All nodes on the tree are initially uncolored, with color .

There are operations. Each operation can be:
- : set the color of all nodes whose distance to node is less than or equal to to .
- : query the color of node .
Input Format
The first line contains two integers , separated by a space.
In the next lines, each line contains one operation, and adjacent integers are separated by a space. It is guaranteed that every operation is valid.
Output Format
For each query operation, output one line containing one integer representing the corresponding answer.
6 6
1 1 1 1
2 3
1 5 2 2
2 4
2 1
2 3
1
2
2
1
Hint
For of the testdata, .
For all testdata, , , , , .
Translated by ChatGPT 5