#P16603. [SYSUCPC 2025] Gray Transform (Weakened)
[SYSUCPC 2025] Gray Transform (Weakened)
题目描述
Gray code is a binary numeral system where two successive values differ in only one bit. This property makes it useful in various applications, such as minimizing errors in digital communication and measurement systems. Gray code is also known for its reflective and cyclic characteristics, which help eliminate significant errors during random sampling. It was invented by Frank Gray in the 1940s and has various construction methods.
An -bit Gray code can be generated by the following algorithm:
- The -bit Gray code consists of the two binary numbers and . That is, .
- The first binary numbers of the -bit Gray code are the same as the -bit Gray code; the last binary strings of the -bit Gray code are formed by taking the -bit Gray code, arranging it in , and then adding to each number. That is, $G_{n+1}=[G_{n,0},G_{n,1},\cdots,G_{n,2^n-1},G_{n,2^n-1}+2^n,G_{n,2^n-2}+2^n,\cdots,G_{n,0}+2^n]$.
For example, , .
Now there is an array of length . Initially, for all , . We will perform operations on this array, where each operation is one of the following two types:
- Given and , for in increasing order, for every , if , then set ; otherwise, do nothing to .
- Given , query the value of .
Please output the results of each query in order.
输入格式
The first line of input contains two integers, which are () and ().
The next lines describe the operations. Each of these lines starts with an integer (), indicating the type of operation.
- If , then the line is followed by an integer () and integers ( for all ), representing a type-1 operation.
- If , then the line is followed by the of an integer () without leading zeros, representing a type-2 operation with parameter .
It is guaranteed that the sum of over all type-1 operations does not exceed .
输出格式
Output the of all the results of the type-2 operations without leading zeros, each on its own line.
3 4
2 0
1 4 1 2 3 2
2 100
2 10
0
110
11
提示
Initially, .
After the second operation, .