A + B
Time limit8sMemory limit512 MB
Given binary numbers A and B, answer the maximum popcount of x in [A, A+B) after bit flips to A or B.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Segment tree
- Solved
- No attempts yet
Problem
Given binary numbers and , process the following queries.
- Output query: print , where is written in binary.
- A change query: flip bit of , counting from the least significant bit as bit 0.
- B change query: flip bit of , counting from the least significant bit as bit 0.
Bit indices are 0-origin. Bit 0 of is the least significant bit.
Input
The input is given in the following format.
...
The first line contains the number of queries , and the binary numbers and . Lines 2 to contain the queries. is an output query. "A " and "B " are change queries that flip bit of and bit of , counting from the least significant bit.
Output
For each output query, print the answer on its own line.
Constraints
- , where is the length of
- For a query "A ",
- For a query "B ",
- is never 0