XOR of Three Numbers and Queries
Time limit2sMemory limit1024 MB
Given an array of values below 64, answer whether some three distinct positions in a range XOR to x, and support adding x mod 64 to every element in a range.
- Level
Medium7 of 10
- Topics
- Segment tree, Bit manipulation, Implementation
- Solved
- No attempts yet
Problem
A sequence of integers of length is given. Write a program that processes the following two kinds of queries.
- 1 : Print 1 if there is an ordered triple with such that . Otherwise, print 0. Here, is the Bitwise XOR operation.
- 2 : For every with , replace with .
Input
The first line contains and , separated by a space.
The second line contains integers , separated by spaces.
Each of the next lines contains one query.
Output
For each query of type 1, print the result on its own line, in the order the queries are given.
Constraints
- For type 1 queries, .
- All numbers in the input are integers.
- The input contains at least one query of type 1.
Hint
Let be a nonnegative integer and a positive integer. Then is the remainder when is divided by . This value is a nonnegative integer.