You are not logged in. Please login at to post your questions!


December challenge -xor of subarray

Hi, In the problem "chef and easy xor queries" of the current december challenge , we need to output the 'number of magical subarrays whose xor of all elements is equal to a certain number'.Can someone explain what 'xor of all elements means'?I had presumed it was the xor was commutative ie (a^b^c) was the same as (a^b)^c,but in the given example , ie the array 1 1 1 1 1 , the number of magical subarrays with xor=1 is 3.How?I can work out the answer to be 2 as the only subarrays with xor 1 are ((a[0]^a[1])^a[2])and(a[0]^a[1]^a[2]^a[3])^a[5]`

Is there something I am not getting?(Not about the problem,but about the concept of xor queries..)

asked 03 Dec '17, 19:45

devildudeja's gravatar image

accept rate: 0%

edited 03 Dec '17, 19:45

The length of a subarray can be 1. So, [A[0],] is also a subarray with xor 1. :)

(03 Dec '17, 20:48) dhruvsomani3★

@devildudeja u might post the above question as comment below the pblm so that it might be useful for them.

(04 Dec '17, 10:10) lokesh20024★

Please dont ask or answer queries related to on going contest, no matter how small or trivial.

(04 Dec '17, 12:13) vijju123 ♦♦4★

It will be better if you ask your problem in comment section of that question.


answered 03 Dec '17, 19:58

shrikantbadri's gravatar image

accept rate: 9%

Didn't know that existed,Thanks.

(03 Dec '17, 20:04) devildudeja2★

a[0] is considered a subarray


answered 04 Dec '17, 02:17

we7d's gravatar image

accept rate: 0%

question CPLAY is so confusing!


answered 05 Dec '17, 13:22

skyhavoc's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 03 Dec '17, 19:45

question was seen: 1,476 times

last updated: 05 Dec '17, 13:22