AlgoUniversity
  • Go Back
Discussion
Xor Operation :

Author

Ujjwal Srivastava

Difficulty Level : Medium

Submissions : 679

Asked In : Zomato

Marks :30

: 14 | : 0

Given an array $$$A$$$ consisting of $$$N$$$ integers. Also given $$$Q$$$ queries along with it.In each query, you are given 3 spaced separated integers $$$L, R$$$ and $$$X$$$. You need to output the summation of XOR of $$$X$$$ with each of the array elements from range $$$L$$$ to $$$R$$$ both inclusive(1- based indexing).

The array does not change after any query.

Input

The first line contains two integers $$$N$$$ and $$$Q$$$. The next line contains $$$N$$$ spaced separated integers $$$A_{i}$$$. The next $$$Q$$$ lines contains 3 integers each $$$L$$$,$$$R$$$ and $$$X$$$.$$$(1 \le N,Q \le 10^5)$$$$$$(1 \le A_{i},X \le 10^9)$$$$$$(1 \le L,R \le N).$$$

Example

Input
5 2
2 3 1 4 5
1 1 3
3 5 2
Output
1
16

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.